Ok I got an solution for my case. Maybe a bit confusing but I did’nt saw anothere possibility to do this. If you know a better way let me know.
First I hide the Edit Item in the Admin Menu:
add_action( 'admin_bar_menu', array($this,'sa_classbook_remove_admin_bar_items'), 999 );
function sa_classbook_remove_admin_bar_items(){
global $wp_admin_bar;
$wp_admin_bar->remove_node('user-admin');
}
Then I check the roles manually:
add_action( 'bp_actions', array($this,'sa_classbook_bp_remove_nav_tabs' ));
function sa_classbook_bp_remove_nav_tabs(){
$current_user = get_user_by("ID",bp_displayed_user_id());
//Only do this if the displayed Profile is not the own
if(bp_displayed_user_id() !== get_current_user_id()) {
//If the Current User is not the Admin
if (!current_user_can('administrator')) {
if (!in_array('sa_classbook_participant', (array)$current_user->roles)) {
//Remove settings
bp_core_remove_nav_item('notifications');
bp_core_remove_nav_item('settings');
bp_core_remove_subnav_item('profile', 'edit');
bp_core_remove_subnav_item('profile', 'change-avatar');
bp_core_remove_subnav_item('profile', 'change-cover-image');
}
}
}
}