Make Private Buddypress Member directory

function make_private_members_profiles(){
// Bail if not a profile page.

if ( ! bp_is_user_profile() && ! bp_is_members_directory() )
return;

// Allow admin users.
if ( current_user_can( 'manage_options' ) )
return;

// Allow the profile owner.
if ( bp_is_user_profile() && bp_loggedin_user_id() == bp_displayed_user_id() )
return;

// If we get to here, redirect to homepage.
bp_core_redirect( home_url() );
}

add_action( 'bp_init', 'make_private_members_profiles') );
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s