Restrict BuddyPress Members Pages from Non-Logged in Users

The following snippet will redirect non-logged in users when visiting your BuddyPress members area.

<?php
function bp_restrict_members() {
 global $bp;
 if (bp_is_page( BP_MEMBERS_SLUG ) ) {
  if( !is_user_logged_in() ) {
   wp_redirect( get_option('siteurl') );
  }
 }
}
add_filter('get_header', 'bp_restrict_members', 1);
?>

Tags: , , , , ,

One Response to “Restrict BuddyPress Members Pages from Non-Logged in Users”

  1. woody May 23, 2011 at 6:11 pm #

    what directory/file would i need to add this code to in order to do that?

Leave a Reply