Skip to content

Instantly share code, notes, and snippets.

@cjuroz
Last active January 5, 2022 03:49
Show Gist options
  • Save cjuroz/23037076e67d0479e0338cedd1be0273 to your computer and use it in GitHub Desktop.
Save cjuroz/23037076e67d0479e0338cedd1be0273 to your computer and use it in GitHub Desktop.
Make a WordPress whole site private (require login)
// 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