• Resolved carterkay

    (@carterkay)


    Hello. Thanks for a great plugin.

    I tried looking in the backend and Add-Ons for a solution but couldn’t see anything for the following issue.

    I need to block non members from every page (apart from a home and contact page), is there a simple global command for this, as I have hundreds of pages, so going in to each one isn’t practical.

    If there isn’t is there an add on that can do this?

    Thanks, Christian

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter carterkay

    (@carterkay)

    I have figured out how to make it all private using the “Enable Private Site” option, but is there a way to make the home page accessible to all?

    Plugin Author Caseproof

    (@caseproof)

    Hi Christian,

    The “Private Site” option makes site private and there’s no option to exclude one of the pages. To achieve what you want you could add the following code snippet at the end of theme’s functions.php file or use one of the plugins like WP Code.

    add_action( 'template_redirect', function() {
      $user = wp_get_current_user();
      if( 
        !is_user_logged_in() && 
        !is_home() && 
        !is_page( 'contact' )
      ) {
        wp_redirect( 'https://your-domain.com/login' );
        exit;
      }
    } );

    It will redirect all not logged in users from entire site except home page and contact page.

    I hope that helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to automatically block all non members from every page’ is closed to new replies.