Multisite User Sync
Recently I’ve developed a user syncronisation plugin which allows to share users between multiple WordPress websites and uses REST API. But when I tried to explore what similar plugins are already out there I found a couple of WordPress Multisite user sync plugins.
And in this moment I don’t fully get it what those plugins do, because users within a multisite network are already shared between blogs.
Let’s figure it out in this post.
Sites within a WordPress Multisite Network Share a Single Database Users Table
It is not even necessery to check the database table intself in order to understand it. We can just go to Network Admin > Users and all the users are listed on a single admin page which obviously means that most likely they are also in the same database table.

Indeed, for posts in WordPress Multisite database we have something like wp_2_posts
, wp_3_posts
etc, but just one table wp_users
.
How to add a user to a blog
Here I am going to share a secret with you – it is not necessary to install a specific user sync plugin in order to add a user to a site within a network.
Just go to Network Admin > Sites, then select a site you need, switch to Users tab and… here you can add users to it!

Syncing Multisite Users in Code
The whole process of WordPress Multisite user sync comes down to using just two functions:
add_user_to_blog()
,remove_user_from_blog()
.
That’s what I was talking about when I said that don’t understand the whole idea of user syncing within a multisite network, because the users are already shared between the sites, all we need to do is just to add/remove a user to a specific site. All right, let’s call this process “syncing/unsyncing” 🙃
Now let’s take a look at the examples below.
Automatically sync users to a specific site after registration
Below is a code snippet you can use in your functions.php
plugin or whatever.
add_action( 'user_register', function( $user_id ) {
if( ! is_multisite() ) {
return;
}
// decide about a blog you would like to sync users to
$blog_id = 2;
// maybe we are already on blog 2?
if( $blog_id === get_current_blog_id() ) {
return;
}
add_user_to_blog( $blog_id, $user_id, 'subscriber' );
// change 'subscriber' to a role name you would like the user to have on Site 2
} );
Here I also decided to use is_multisite()
function to double check if the snippet is currently used on a site which is a part of a multisite network, function_exists( 'add_user_to_blog' )
should also do the trick.
Unsync users
$user_id = 552;
$blog_id = 2;
remove_user_from_blog( $user_id, $blog_id );
As simple as that guys.
Have any questions? Let’s discuss it in the comments!

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me