Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6155
    centraldeco
    Participant

    Hi!
    I would like to limit my whole WordPress site to only logged-in users.
    Is there a setting with User Role Editor plugin to redirect visitors to login page?
    Regards.

    #6157
    Vladimir
    Keymaster

    Hi,

    Content view restrictions add-on includes ‘Logged in only” and redirection action for selected posts/pages in case of access error. If redirection URL field is empty, visitor is redirected to login page.

    URE does not have similar option for a whole website. You need install another plugin or custom code for this purpose, like this:

    
    // Redirect users who arent logged in...
    function members_only() {
        global $pagenow;
        // Check to see if user in not logged in and not on the login page
        if( !is_user_logged_in() && $pagenow != 'wp-login.php' )
              auth_redirect();
    }
    add_action( 'wp', 'members_only' ); 
    

    Code sample was taken here.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.