WordPress redirect to landing page if not logged in

something like:

if (
  !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))
  && !is_admin()
  && !is_user_logged_in()
) {
  wp_redirect('http://www.mysite.com/landingpage', 301);
  exit;
}

should do it.

see http://codex.wordpress.org/Function_Reference/is_admin &
Check if wp-login is current page

Leave a Comment

tech