Created
August 2, 2012 08:30
-
-
Save onishiweb/3235432 to your computer and use it in GitHub Desktop.
WordPress - Force users to log in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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