Redirect If Not Logged In
-
Hello,
I am using the following script to redirect any users not logged into my site to the login page.
if ( !in_array($GLOBALS[‘pagenow’], array(‘wp-login.php’, ‘wp-register.php’)) && !is_admin() && !is_user_logged_in() ) { wp_redirect(‘https://mydomain.net/wp-login.php’, 301); exit; }
However, there are a few pages that I want non logged in users to be able to view such as my landing page, shopping cart page etc. What code can I add to this script to permit certain page exceptions.
Thanks,
Matt[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Redirect If Not Logged In’ is closed to new replies.