BuddyDev

Search

[Resolved] Hide Nav Item Function only works for core BP items

Tagged: ,

  • Participant
    Level: Initiated
    Posts: 5
    arnotzon on #27063

    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?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #27072

    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
    Brajesh

  • Participant
    Level: Initiated
    Posts: 5
    arnotzon on #27084

    Thanks for your reply Brajesh. I tried MediaPress, rtMedia and BP Member Reviews but the function works with neither of these plugins. I thought there was maybe another solution for hiding nav items.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #27086

    Hi,
    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.

This topic is: resolved