Hi,
I’m trying to hide some nav tabs for specific role. I tried this function:
function remove_tab_by_displayed_role() { // Get Current User Data. $user = get_userdata( bp_displayed_user_id() ); // Get Roles. $roles = (array) $user->roles; if (in_array( 'donor', $roles ) ) { bp_core_remove_nav_item( 'activity' ); bp_core_remove_nav_item( 'media' ); } } add_action( 'bp_setup_nav', 'remove_tab_by_displayed_role', 15 );
It works perfectly for core BP nav items such as “profile or “activity” but doesn’t for other tabs such as “media”, “ratings”, etc. I tried to change the priority from 15 to 9999 but it doesn’t work either.
Can somebody help?
It is mostly due to the plugin you are using.
Please let me know if you are using MediaPress, We can assist.Otherwise, I will recommend to ask in the relevant plugin’s support forum.
Regards
BrajeshHi,
You are using the correct function.bp_core_remove_nav_item
That is used for removing nav item.
It is related to priority and hook on which the plugins have attached/created nav items.
Regards
Brajesh
The topic ‘ [Resolved] Hide Nav Item Function only works for core BP items’ is closed to new replies.