Skip to content

Instantly share code, notes, and snippets.

@onishiweb
Created August 2, 2012 08:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onishiweb/3235432 to your computer and use it in GitHub Desktop.
Save onishiweb/3235432 to your computer and use it in GitHub Desktop.
WordPress - Force users to log in
// Put this at the top of your functions.php file
// Force users to login...
add_action( 'template_redirect', 'force_login' );
function force_login () {
if ( ! is_user_logged_in() ):
// Redirect to the login screen
header( 'Location: /wp-login.php?redirect_to=/' );
die();
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment