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?