Skip to content

Instantly share code, notes, and snippets.

@dcavins
Created March 3, 2018 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcavins/e7708f2a58aab16b61bbf7b06acf9756 to your computer and use it in GitHub Desktop.
Save dcavins/e7708f2a58aab16b61bbf7b06acf9756 to your computer and use it in GitHub Desktop.
Don't allow people to see a subscriber's profile tab.
add_action( 'bp_actions', function() {
if ( ! bp_is_user() || is_super_admin() ) {
return;
}
$user_meta = get_userdata( bp_displayed_user_id() );
if ( in_array( 'subscriber', $user_meta->roles ) ) {
bp_core_remove_nav_item( 'profile', 'members' )
}
}, 1 );
@kwavewd
Copy link

kwavewd commented Mar 3, 2018

this accomplished the blocking of profile page but still gives subscriber access to it's other pages like messages/ buddydrive.

add_action( 'wp', function() {
if ( bp_is_user_profile() ) {
$user_meta = get_userdata( bp_displayed_user_id() );

    if ( in_array( 'subscriber', $user_meta->roles ) ) {
        wp_redirect( home_url() );
        exit;
    }
}

}, 1 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment