Last active
August 29, 2015 14:22
-
-
Save marcbacon/b6283815678b5f45f693 to your computer and use it in GitHub Desktop.
If a visitor is not logged into the WordPress site, send them directly to the login page. After they have logged in, redirect them back to the home page.
This file contains hidden or 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
// Place in functions.php or in a plugin | |
function redirection() { | |
if ( ! is_user_logged_in() ) { | |
wp_redirect( '/wp-login.php?redirect_to=' . home_url() ); | |
exit; | |
} | |
} // end function | |
add_action( 'get_header', 'redirection' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment