Primary Blog Switcher for SuperAdmins

WordPress Multisite network plugin to allow Network Admin to set the “Primary Blog” (aka Primary Site) of a user while editing a user’s profile.

Well, for whatever reasons (usually users fiddling around – I use WP multisite in a school with students grades 4-12), users aren’t attached(or become unattached) to the correct “Primary Blog”.

This isn’t a deal breaker, but annoying when they login and are redirected to a blog that is not their expected primary. It also is annoying when I use other plugins to list user primary blog for display in a member directory, member profiles, etc.

Telling users to reset their primary blog at their own Dashboard->My Blogs is a fix, but the SuperAdmin(Teacher in my case) can head off the confusion first with this plugin. There is no other way(AFAIK) for the Network Admin to set the “Primary Blog” of a user while editing their profile.

Now, I can quickly scan the Network Admin list of users and edit profiles and set primary blogs of any user correctly.

I can also use my Menus plugin to toggle the My Sites menu item so users can no longer fiddle with the Primary Site switcher at all. Problem solved.


The original code for the Primary Site switcher is in wp-admin-includes/ms.php. I’ve basically copied that, but changed get_current_user_id() to $edit_user = (int) $_GET['user_id']; and added it to the “edit_user_profile” hook.

The plugin can be used to add users to a “Special Blog” by uncomment(remove the /* and */) this section in the plugin code and change the $special_blog_id:

<optgroup label="Other Blogs"></optgroup>
<optgroup label="Special Blog">
<?php $special_blog_id = '63'; //
$special_blog = get_blog_details( $special_blog_id ); ?>
<option value='<?php echo $special_blog_id ?>'>http://<?php echo $special_blog->domain.$special_blog->path ?></option>


Latest version: Download Primary Blog Switcher for SuperAdmins v4.6 [zip]
Primary Blog Switcher for SuperAdmins at WordPress Plugin Repository


This section describes how to install the plugin and get it working.

  1. Upload the plugin to your blog, Network Activate it
  2. Edit user profiles as Network Dashboard->Users->Edit
  3. View Network Dashboard for notices of users who have the main blog set as their primary blog, or no blog at all.



  • WP 4.6 tests OK, cleanup php notices

2 Responses to Primary Blog Switcher for SuperAdmins

  1. sonic says:


    Thanks for your plugin : primary-blog-switcher-for-superadmins.
    May I ask you a question ?

    In Database Table ‘usermeta’, every user have a meta “primary_blog”, who decide this value ? how do I set default value for “primary_blog” ?

    thank you.


    • dsader says:

      who decides this value?

      WP has a variety of methods the code sets a new and existing user’s primary_blog usermeta:

      The model I used in this plugin is the function choose_primary_blog(); added to the user’s Dashboard->My Sites page (the function choose_primary_blog is defined in ms.php).

      how do I set default value for “primary_blog” ?

      With your own custom plugin:
      To set the user’s default primary would also need a plugin function with “update_user_meta( $user_id, ‘primary_blog’, $blog_id );” Something similar to the function I have in this plugin: profile_update_primary_blog(). You could have that function add_action in a variety of places, too: new user creation, new blog creation, any update to the user profie page etc.

      With this plugin:
      When I need to set a user’s primary blog, I first add them as a user to their (soon to be) primary site at Network Admin->Sites, then edit their profile via Network Admin->Users using the dropdown selector added by this plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *