BuddyDev

Search

[Resolved] Disable BuddyPress Admin Bar and remove CSS blank for user

Tagged: 

  • Participant
    Level: Initiated
    Posts: 10
    Alexandre Brunet on #10869

    Hi Buddydevs,

    I added in function.php of my theme the following code to remove for the users the Admin bar as well as the Blank left after doing so on top of the page :
    ‘ add_action(‘after_setup_theme’, ‘remove_admin_bar_user’);
    function remove_admin_bar_user() {
    if (current_user_can(‘administrator’) || is_admin() ) {
    show_admin_bar(true);
    }else{
    show_admin_bar(false);
    }
    } ‘

    it’s working for all the pages not directly controled by buddypress (home, blog,…) for the other pages (member, forum, …) nevertheless, if the admin bar is indeed removed, the blank remains. Could you help me on this ? What and where should I put some code to remove the blank on top between my header and the top of my page.

    Many thanks in advance,

    Cheers,

  • Keymaster
    (BuddyDev Team)
    Posts: 24315
    Brajesh Singh on #10886

    Hi Alexandre,
    Please try hooking to ‘init’ section and it should work.

    Here is your code with init action

    
    
    add_action( 'init', 'remove_admin_bar_user', 10001 );
    function remove_admin_bar_user() {
    
    	if ( current_user_can( 'administrator' ) || is_admin() ) {
    
    		show_admin_bar( true );
    	} else {
    		show_admin_bar( false );
    	}
    }
    
    

    Does it work?

    • This reply was modified 6 years, 8 months ago by Brajesh Singh. Reason: Updated privacy to normal
    • This reply was modified 6 years, 8 months ago by Brajesh Singh. Reason: Updated priority to normal
  • Participant
    Level: Initiated
    Posts: 10
    Alexandre Brunet on #10891

    It’s Working !

    Many thanks for your quick and great answer,

    Cheers,

  • Keymaster
    (BuddyDev Team)
    Posts: 24315
    Brajesh Singh on #10927

    You are welcome 🙂

The topic ‘ [Resolved] Disable BuddyPress Admin Bar and remove CSS blank for user’ is closed to new replies.

This topic is: resolved