Remove BuddyPress admin bar from all blog except the main BuddyPress site
Do you want to remove BuddyPress admin bar from all blog except the blog on which BuddyPress is activated ?
Here is a small snippet of code that you can use to remove the BuddyPress admin bar. You can put it into a file and drop in to mu-plugins directory or use put it inside bp-custom.php.
1 2 3 4 5 6 7 8 9 10 | function buddydev_remove_bpadminbar() { if ( ! bp_is_root_blog() ) { //if current blog is not the one on which buddypress is activate remove_action( 'wp_footer', 'bp_core_admin_bar', 8 );//remove buddypress admin bar } } add_action( 'wp', 'buddydev_remove_bpadminbar' ); |
Happy social networking with BuddyPress 🙂 Let me know in comments how it worked for you.
Hi Brajesh,
I've been trying to adjust this code to my needs but with no luck 🙁
I'd have a single blog on a WP3.0 network site that I'd like the BP adminbar not to display on. The Blog ID = 3.
Can you please point me to a possible solution? Thanks in advance for your help.
Cheers
Paul
Hi Paul,
Thanks for the comment. Please change the line
if($current_site->blog_id!=BP_ROOT_BLOG)
to
if($current_site->blog_id==3)
and It should work for you. Please do let me know if it works or not.
Thanks
Brajesh
Thanks Brajesh,
unfortunately that didnt work.
here's the code I used for your reference…
blog_id==3) //if current blog is not the one on which buddypress is activated
{
remove_action( 'wp_footer', 'bp_core_admin_bar', 8 );//remove buddypress admin bar
}
}
add_action("wp","remove_bpadminbar");
?>
Sorry, that code didnt paste in correctly…..
blog_id==3) //if current blog is not the one on which buddypress is activated
{
remove_action( 'wp_footer', 'bp_core_admin_bar', 8 );//remove buddypress admin bar
}
}
add_action("wp","remove_bpadminbar");
?>
@Paul
have you put the code in wp-content/plugins/bp-custom.php ?
Yes. wp-content/plugins/bp-custom.php
@Paul I dunno if you still check up on this but I think the reason yours doesn't work is that "<?php" is missing from the beginning of the code snippet. Posting this for Googlers that got here like I did.
it should be:
blog_id!=BP_ROOT_BLOG) //if current blog is not the one on which buddypress is activated
{
remove_action( 'wp_footer', 'bp_core_admin_bar', 8 );//remove buddypress admin bar
}
}
add_action("wp","remove_bpadminbar");
?>
Sorry I forgot the <?php too, go figure.