Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide admin bar component for some users


  • asianowl
    Participant

    @asianowl

    I have a website where members are registered with one of two roles. For one of the roles, I want to hide the ‘activity’ component. I was able to remove the component for the user navigation menu using bp_core_remove_nav_item( 'activity') but the link still shows up in the admin bar.

    Could you someone please help point me in the right direction? I need to hide the ‘activity’ component from user with role A and leave it as is for user with role B.

    I tried $wp_admin_bar -> remove_menu('activity') but it didn’t work.

    Thank you!

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

  • asianowl
    Participant

    @asianowl

    after a shower — it came to me that I should just hide the menu item in CSS with the following:
    #wp-admin-bar-my-account-activity{display:none;}

    But this hides it from everyone… does anyone else have a better idea?


    asianowl
    Participant

    @asianowl

    Found the solution! It was written up in the documentation! HERE

    For my needs, I filtered based on roles like so:

    function my_remove_activity_menu(){
    	if (current_user_can('special_role'))
    	{
    		global $wp_admin_bar;
    
    		$wp_admin_bar->remove_menu('my-account-activity');
    	}
    }
    add_action('bp_setup_admin_bar', 'my_remove_activity_menu',301);
    

    Good luck everyone.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide admin bar component for some users’ is closed to new replies.
Skip to toolbar