Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I get the slug for a tab I want to hide?


  • panosa1973
    Participant

    @panosa1973

    WordPress 4.9.5 -> BuddyPress 2.9.4

    Hi all,
    This is when viewing a user’s profile page. I removed the Friends tab with the below code but the View tab is still showing (it’s not necessary since the Profile tab is there and points to the same place, the user’s profile page). Is there a list somewhere of the slugs for the tabs or is there a function that can generate that? Or am I completely off about this 🙂
    Thanks in advance.

    function remove_nav_items() {
    if ( !bp_is_my_profile() && !is_super_admin()) {
    bp_core_remove_nav_item( 'friends' );
    bp_core_remove_nav_item( 'view' );
    }
    }
    add_action( 'bp_setup_nav', 'remove_nav_items',301);

Viewing 4 replies - 1 through 4 (of 4 total)

  • Varun Dubey
    Participant

    @vapvarun

    @panosa1973
    First sub nav points to the primary tab for all core tabs

    To remove sub nav you can use the following approach, but it will not work for first sub nav like the view

    // remove nav forums and coures 
    function bb_remove_extra_tab() { 
         global $bp;      
    bp_core_remove_nav_item( 'friends' );   
    bp_core_remove_subnav_item( 'profile', 'edit' );
    } 
    add_action( 'bp_actions', 'bb_remove_extra_tab', 999 );

    panosa1973
    Participant

    @panosa1973

    Thanks for your reply. I tried your code but it doesn’t do anything. My Friends tab was already removed. I want to remove the View tab. When you say “it will not work for first sub nav like the view” do you mean there’s no way to remove the View tab?
    Thank again.


    panosa1973
    Participant

    @panosa1973

    I managed to hide the View tab with CSS:

    function remove_some_tabs() {
        if ( !is_super_admin()) {
    		//This hides the View tab
    		echo '<style>li#public-personal-li {Display: none;} </style>';
    		//This hides the additional members input box when sending a msg
    		echo '<style>#send-to-input {Display: none;} </style>';        
    	}
    }
    add_action( 'wp_head', 'remove_some_tabs');

    Varun Dubey
    Participant

    @vapvarun

    Nice approach 🙂 Glad it worked

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar