Remove Toolbar options on WordPress Multisite

How to remove the dropdowns in your toolbar, the little black bar at the top of the page you see when you’re logged in, in a WordPress multisite install.  Many like to customize the experience a user gets when they sign up for a site so this function comes in handy.

These are most of them, but you can find more by viewing the source code and searching for wp-admin-bar- the id is the stuff that comes right after that in each case. So to remove the WP logo, you’ll see wp-admin-bar-wp-logo. “wp-logo” is the id and you use that to remove it in the function.

Slightly more involved is the foreach loop in the function that removes the new posts link that drops down from the “My Sites” Nav item. For example, I used some custom post types and not the “post” post type, so I wanted to delete that and keep the My Sites dropdown super simple. So it checks for all blogs created by the user in the foreach and adds them to their own unique id to remove them.


add_action( 'admin_bar_menu', 'remove_toolbar_items', PHP_INT_MAX -1 );
function remove_toolbar_items( $bar )
    $sites = get_blogs_of_user( get_current_user_id() );
    foreach ( $sites as $site )
       $bar->remove_node( "blog-{$site->userblog_id}-n" ); // posts 
		$bar->remove_node( "blog-{$site->userblog_id}-c" ); // comments
       // $bar->remove_node( "blog-{$site->userblog_id}-d" ); // dashboard
    $bar->remove_node( 'new-media' ); // +Post
    $bar->remove_node( 'wp-logo' ); // WP logo
	$bar->remove_node( 'new-user' ); // New User
	$bar->remove_node( 'new-post' ); // New Post
	$bar->remove_node( 'new-content' ); // ?
	$bar->remove_node( 'comments' ); // Comments bubble