Skip to:

Re: procedure for removing Admin Bar Sub Nav item

Burt Adsit


Mike the idea is that if I want to change the function of a menu item, I have to replace the menu item with something of my own. I want to change “My Account” on the bar and add a new item underneath entitled: “I Owe Mike How Much!?”. I have to replace the entire “My Account” menu item since the granularity of the actions are at the top level menu item only.

I can slide new menu items in between existing items easily but that’s the way it has to happen for drop down items.

I create a plugin that runs in /mu-plugins since I want this to run all the time for all users on all blogs. It’ll get run every page load.

An example is replacing the bp logo image in the bar. Same technique for other menu items. The item gets rendered through the function:

bp_adminbar_logo() in bp-core-adminbar.php

This function gets registered in mu by us telling mu about this function and when to trigger it:

add_action( ‘bp-adminbar-logo’, ‘bp_adminbar_logo’ ) at the bottom of bp-core-adminbar.php

To replace the logo with our own logo or do something completely diff like just use the word ‘Home’, whatever we unregister the existing fn, register our own that replaces the old fn and does something different. Like below:

function oci_adminbar_logo() {
global $bp;
echo '<a href="' . $bp['root_domain'] . '"><img id="admin-bar-logo" src="' . apply_filters( 'bp_admin_bar_logo_src', site_url( MUPLUGINDIR . '/common-interest/images/oci_home.gif' ) ) . '" alt="' . apply_filters( 'bp_admin_bar_logo_alt_text', __( 'BuddyPress', 'buddypress' ) ) . '" /></a>';


The above says “don’t pay any more attention to the function bp_adminbar_logo() when the action ‘bp-adminbar-logo’ occurs, pay attention to my oci_adminbar_logo() fn and do that instead.

You have to replace the *entire* menu item with something of your own. Clearer? No?

Skip to toolbar