Private Site with BuddyPress Print

  • 0

How to make your entire wordpress site private, including BuddyPress pages. This snippet will redirect all non-logged in users to the log-in page.

Add the following to the functions.php file of your child theme:

//Private Site Snippets
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('get_header', 'make_wordpress_site_private');

  


Was this answer helpful?

« Back