Last active
January 5, 2022 03:49
-
-
Save cjuroz/23037076e67d0479e0338cedd1be0273 to your computer and use it in GitHub Desktop.
Make a WordPress whole site private (require login)
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
// Make site private | |
function make_wordpress_site_private(){ | |
global $wp; | |
if (!is_user_logged_in() && $GLOBALS['pagenow'] !== 'wp-login.php'){ | |
wp_redirect(wp_login_url($wp -> request)); | |
exit; | |
} | |
} | |
add_action('wp', 'make_wordpress_site_private'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment