"My Sites" Dropdown Options and Position

Hello, I have a multisite setup with buddypress network in which members register to create multiple blogs under their account(using pro-sites plugin), the only problem is that I need the main site (id=1) not to be displayed to members, only to super admin user and users with administration role to the main site.

I understand that by default it is displayed to every member because they have network (buddypress) role but they're not administrators of the main site, so for that reason they shoulnt get that option under "My Sites" from both the adminbar nor the dashboard page my-sites.php nor anywhere else, meaning that it must be a global setting.

Also, instead of having the "My Sites" dropdown menu on the left side of the adminbar, I need it to be under the profile menu (Between the profile and notifications, please see screenshot.)

And last thing, when you hover one of the sites displayed under "My Sites", I would only like to get "Dashboard, and Visit Site" links , nothing else. (would be nice to get rid of the wordpress logo too, and display the sites in alphabetical order)

Please advise. I have granted "Support Access" in case you need to look at my dashboard and settings.

  • Vaughan

    Hi Carlos,

    Hope you're well?

    To remove the main blog from the my sites list for non admins.

    Create a file called my_sites_admin_bar.php

    In this file add the following code.

    add_action('admin_bar_menu', 'remove_root_blog');
    function remove_root_blog($wp_admin_bar) {
        $canView = false;
        if($current_user_can('manage_options')) {
            $canView = true;
        if(!$canView) {
            $blog_id = 1;
            $mysites = $wp_admin_bar->user->{'blogs'};
            $blogs = array();
            foreach($mysites as $id => $info) {
                $blogs[$id] = strip_tags($info->blogname);
            $blogs = array_map('strtoupper', $blogs);
            foreach ($blogs as $id => $title) {
                $wp_admin_bar->user->{'blogs'}->$id = $mysites[$id];

    Now upload this file to /wp-content/mu-plugins/

    If /mu-plugins does not exist, create it.

    This should now hide the main site from the my sites menu for everyone who is not an admin of the main site.

    With regards to moving the my sites menu into the buddypress menu, this would be quite difficult as it's designed for the admin_bar itself.

    Essentially what you would need to do is to completely recreate the whole my sites function and then edit the buddypress code to re-add it to the bp menu. not an easy task at all.

    But you could move it to the right side so it appears next to the avatar. for this you could use the Ultimate branding plugin and enable the custom admin bar module.

    With UB plugin, this will also allow you to disable default admin_bar items including the WP logo, it will also allow you to create custom admin bar menu too.


    To hide the new post & new comments from the mysites submenu.

    Add the following code to the end of the file you just added to mu-plugins.

    I haven't tested this bit of code though, so it might not work first time.

    add_action( 'admin_bar_menu', 'remove_nodes_from_mysites', 999 );
    function remove_nodes_from_mysites( $wp_admin_bar ) {
        $blog_ids = wp_get_sites();
        foreach($blog_ids as $key) {
            foreach($key as $k => $val) {
                $node_id = $k['blog_id'];
                $wp_admin_bar->remove_node( "wp-admin-bar-blog-{$node_id}-n" );
                $wp_admin_bar->remove_node( "wp-admin-bar-blog-{$node_id}-c" );

    Hope this helps

  • Carlos

    Thank you very much for helping ... I already use the Ultimate Branding plugin but it doesnt remove the Wordpress logo from the sites list (look at screenshot) ... The first code to remove the main site from members without admin persmissions breaks the site, the second code even worse. Could you please test it ? I copied and pasted the codes without altering them whatsoever . please let me know

    Also please don't forget the code to limiting the sites links to just "Dashboard and Visit Site" (Not at the admin bar as, but under the sites list under each site

  • Vaughan


    In the first bit of code, I made a small error.

    remove the $ from this line.

    if($current_user_can('manage_options')) {

    So it looks like;

    if(current_user_can('manage_options')) {

    Ok I misunderstood which wp_logo you was referring to.

    The following function should sort the wp logo for you.

    function wpmu_replace_blavatars() {
    echo '<style>
    #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {content:" "!important;}
    #wpadminbar .quicklinks li .blavatar:before {content:" "!important;}
    add_action('admin_head', 'wpmu_replace_blavatars');

    Hope this helps

  • Carlos

    First function seems to work but displayed an error message now ...

    Warning: Creating default object from empty value in /home/vefusion/public_html/wp-content/mu-plugins/my_sites_admin_bar.php on line 28

    This is what's in line 28
    $wp_admin_bar->user->{'blogs'}->$id = $mysites[$id];

    Now the problem is that is not a global setting as I had mentioned.. if the user goes to /my-sites.php he can still see the main site without having admin permissions. he can see it on both the primary site dropdown selection and the list displayed on the page.

  • Carlos

    How does support work here? Sent me untested code that didn't work, and then the corrected one worked but displayed an error message ( Warning: Creating default object from empty value in /home/vefusion/public_html/wp-content/mu-plugins/my_sites_admin_bar.php on line 28 ) ... and then at the end explained that I had mentioned (from the beginning) that I needed it to be a global setting, or a least at the places I pointed ( /my-sites.php both the dropdown and the list) and at the end abandoned me?

    Guys, I understand you might get tons of emails a day but if clients are being abandoned like this, the company needs to either hire more support people, or stop acquiring more clients that pay to get premium support and at the end only leaves us disappointed.

    Will we get this straighten out? Please let me know to see where I stand.

  • Hoang Ngo

    Hi @Carlos,

    For the last issue, could you please try this?

    add_filter( 'get_blogs_of_user', 'filter_out_blogs_of_user', 20, 2 );
    function filter_out_blogs_of_user( $blogs, $user_id ) {
    	if ( user_can( $user_id, 'manage_network' ) ) {
    		//super admin
    		//return $blogs;
    	foreach ( $blogs as $key => $blog ) {
    		$users = get_users( array(
    			'blog_id' => $blog->userblog_id,
    			'role'    => 'administrator',
    			'fields'  => 'user_id'
    		) );
    		if ( ! in_array( $user_id, $users ) ) {
    			unset( $blog[ $key ] );
    	return $blogs;

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.