Skip to content

Instantly share code, notes, and snippets.

@robi09
Created July 25, 2016 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robi09/0342ae1508593c16b876fcc3f06b2dfd to your computer and use it in GitHub Desktop.
Save robi09/0342ae1508593c16b876fcc3f06b2dfd to your computer and use it in GitHub Desktop.
Force login page WordPress
function redirect_login_page() {
$login_page = home_url('/login/');
$page_viewed = basename($_SERVER['REQUEST_URI']);
if($page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
wp_redirect($login_page);
exit;
}
}
add_action('init','redirect_login_page');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment