i found out that it only work when i try to remove a core buddypress nav like ‘messages’ or ‘friends’. With a custom nav or subnav it doesn’t work. Any ideas why?
Hi, thank you for your message. The link shows solutions for the role a visitor has when on a profile page. I would like to remove a tab on a profile when the profile owner (bp_displayed_user_id) doesn’t have a certain role.
I think i am close but i could be miles off:(
Here is where i am but it doesnt work
//Disable bookings subnav by role of the displayed user id.
function remove_bookingtab_by_displayed_role() {
// Get Current User Data.
$user = get_userdata( bp_displayed_user_id() );
// Get Roles.
$roles = (array) $user->roles;
// exclamationmark means not in array i hope
if (!in_array( 'translator', $roles ) ) {
bp_core_remove_subnav_item( 'bookings','booking' );
}
}
add_action( 'bp_setup_nav', 'function remove_bookingtab_by_displayed_role', 15 );