How to Disable the BuddyPress Admin Menu Bar in WordPress

Home » Snippets » How to Disable the BuddyPress Admin Menu Bar in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Are you a WordPress site owner who wants to disable the admin menu bar that comes with BuddyPress? Although this menu bar is handy for some, you might want to remove it just to simplify things. If you’re looking for the solution, you’ve come to the right place. In this article, we’ll guide you through the process of disabling the BuddyPress admin menu bar and getting the clean interface you’re looking for. So let’s dive in and get started.

					function wpturbo_disable_bp_admin_bar() {
  if( is_super_admin() ) {
    show_admin_bar( true );
    return;
  }

  global $wp_admin_bar;
  $wp_admin_bar->remove_menu( 'bp-admin-bar-logo' );
  $wp_admin_bar->remove_menu( 'bp-admin-bar-account' );
  $wp_admin_bar->remove_menu( 'my-account-buddypress' );
  $wp_admin_bar->remove_menu( 'bp-login-register' );
  $wp_admin_bar->remove_menu( 'bp-admin-bar-notifications' );
  $wp_admin_bar->remove_menu( 'bp-admin-bar-settings' );
  $wp_admin_bar->remove_menu( 'bp-admin-bar-logout' );
}
add_action( 'wp_before_admin_bar_render', 'wpturbo_disable_bp_admin_bar', 999 );
				

In this tutorial, I will show you how to disable the BuddyPress admin menu bar in WordPress by using some PHP code.

Firstly, we define a new function called wpturbo_disable_bp_admin_bar(). This function will be responsible for removing the BuddyPress admin menu bar from WordPress when activated.

Next, we check if the current user is a super admin. If so, we don’t remove the BuddyPress admin menu bar. We use the is_super_admin() function to check if the current user is a super admin. If not, the function continues to remove the BuddyPress admin menu bar.

The next step involves removing the different BuddyPress admin menu items from WordPress. To do this, we use the global variables $wp_admin_bar to access and remove the BuddyPress admin menu items.

For example, to remove the "Account" menu item, we use the following line of PHP:

$wp_admin_bar->remove_menu( 'bp-admin-bar-account' );

We repeat this process for each of the BuddyPress admin menu items we want to remove.

Finally, we use the add_action() function to add the wpturbo_disable_bp_admin_bar() function to the wp_before_admin_bar_render action. This ensures that the function is run before WordPress renders the admin menu bar, so the BuddyPress admin menu bar is not displayed. We set the priority of the function to 999 to ensure it runs last in the list of actions.

Register an account to save your snippets or go Pro to get more features.