My Sites dropdown list do not show up new sites

Hello Support

I have a big problem suddenly.
I just created 2 new sites in my multisite, and all users in this mulisite are Super Admin, so that it should be show up all sites from their My Sites dropdown list, however, it is not working now.

All super admin cannot see the new sites from My Sites dropdown list until I manually add them to the new site or they need to go Network Admin?Sites?All Sites to access those new sites.

Do you have members experienced this issue? can you please teach me how to fix it?

B.Rgds
Eric

  • Luís

    Hi IT ,

    Hope you're doing well today!

    If I understood well your question, in the My Sites dropdown menu, it will be shown all the subsites where the user is the "Admin" user.

    All super admin cannot see the new sites from My Sites dropdown list until I manually add them to the new site or they need to go Network Admin?Sites?All Sites to access those new sites.

    When you create a new subsite on the network, the super admin is not automatically added, however, he/she have access to all sites on the network.

    So, your assumption is right, even the user is a "super admin" will not be able to see the new sites from My Sites dropdown list until you add it as a user on that site.

    Cheers, Luís

  • Ash

    Hello Eric

    Please use the following code:

    add_action( 'wpmu_new_blog', function( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
            $super_admins = array( 2, 5, 8, 13, 29 );
            foreach( $super_admins as $super_admin )
            {
                    add_user_to_blog( $blog_id, $super_admin, 'administrator' );
            }
    }, 10, 6 );

    In the $super_admins array, you have to give the IDs of super admins separated by comma as per example I showed above.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • IT

    Thanks Ash

    I have tested and confirmed this is work!!
    So I understand I will need to add/remove any super admin into this code, if there are any employee leaving company or joining to company, this is better than I need to add them to all sites..

    Thank you.

    And I confirmed this code will not impact the other code that your colleague taught me

    /** remove a specific site from sites list in Network -> Sites -> All Sites */
    add_action('parse_site_query', 'wpmudev_remove_specific_site_from_list', 999);
    function wpmudev_remove_specific_site_from_list( $wp_site_query ){

    /*$site_id = '34';*/

    $wp_site_query->query_vars['site__not_in'] = array( 34, 36 );

    return $wp_site_query;
    }

    Thanks again!!!

    Besides, can you please teach me, what is the mean for "999" on above code?

    B.Rgds
    Eric

  • James Morris

    Hello IT,

    I hope you are well today.

    999 in the add_action hook is the hook priority. This effectively tells WordPress that this add_action hook should be executed last.

    For example, a hook with a priority of 9 will have a lower priority than one of 99. The higher the number, the later the hook will be run. This is particularly important for overriding functions in plugins.

    See the following for more information: https://developer.wordpress.org/reference/functions/add_action/

    I hope this clarifies a bit.

    Best regards,

    James Morris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.