Created
January 6, 2020 13:48
-
-
Save webdados/55728b5e9a5969157f488febf11bc493 to your computer and use it in GitHub Desktop.
Poor guy's Private WordPress Website - Redirect a user to the login form if he's not logged 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
<?php | |
add_action( 'template_redirect', 'redirect_if_not_logged_in' ); | |
function redirect_if_not_logged_in() { | |
if ( ! is_user_logged_in() ) wp_redirect( wp_login_url( $_SERVER['REQUEST_URI'] ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment