1

I have a multi-network site, and so there's a menu in the WP Admin Bar that says "My Sites," and contains a list of the user's sites. I'd like to remove the root site from this list. I thought it'd be as easy as:

function my_remove_commons_link_from_my_sites() {
        global $wp_admin_bar;
        if (!is_admin() && !is_super_admin()) {
                _log("Removing this crazy business.");
                $wp_admin_bar->remove_node('blog-1');
                _log($wp_admin_bar->get_nodes());
        }

}
add_action( 'admin_bar_menu', 'my_remove_commons_link_from_my_sites', 9999 );

(Where _log is just a function I have to write stuff to the log file.) I notice that in the log file, the list of nodes is missing blog-1, so it looks like this function successfully removed the node. Yet it is still there in the final display. Is something else creating this menu item, after I've removed it? How can I remove this menu item?

2

1 Answer 1

1

You need to hook into 'wp_before_admin_bar_render', not 'admin_bar_menu'. According to the documentation an action attached to this hook fires before the admin bar is rendered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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