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 );
add_action( 'bp_setup_nav', 'function remove_bookingtab_by_displayed_role', 15 );
Please replace the above line with this:
add_action( 'bp_setup_nav', 'remove_bookingtab_by_displayed_role', 15 );
hi, thanks for pointing that out. it still doesn’t work. could you point me in a direction where the problem could be?
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,
Please try changing the priority from ’15’ to ‘9999’ and then test.
Thanks
YES!!!
Thank you so much for your help.