WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using a WordPress multisite network with Buddypress. In order to modify the top nav bar, I've written a function to replace part of the menu. Calling it thus:

add_action('bp_adminbar_menus', 'new_adminbar_blogs_menu', 6);

remove_action('bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6);

Works perfectly in my functions.php, but when I try to move the above code to the plugin file, the remove_action fails to fire, but the add_action works as expected.

As a temporary solution, renaming the function folder to something appearing after Buddypress alphabetically solved the issue.

share|improve this question
up vote 1 down vote accepted

I am not sure about BuddyPress specifics.

In general case remove doesn't work when it is firing before function is actually added to the hook. Between core, plugins, parent and child themes there are a lot of relative combinations of add/remove possible.

In such case to make remove fire properly you need to wrap it into function and hook that wrapper function to some point later, after add.

share|improve this answer

Hi @Chris Cox:

I'm not sure, but I have a guess. Are those two lines of code just listed off by themselves in your theme's functions.php file, or are they wrapped in an 'init' hook? If not, or you don't know what I'm talking about then here's the code I think you need to include in your plugin:

function yourplugin_init() {
  add_action('bp_adminbar_menus', 'new_adminbar_blogs_menu', 6);
  remove_action('bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6);
share|improve this answer

You must check, how was fired this inside BP; maybe the hook plugins_loaded cam later as the functions.php of the Theme, she is very fast and before plugins. You can set a new priotity wuth the value. Add your plugin via init-hook and after this include your remove_action.

share|improve this answer

BuddyPress has its own 'init' function, check the docs for that. As Mike said your BuddyPress is loaded before your functions.php.


This will help you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.