WordPress Multisite: How to Add a User to All Sites
![A laptop with a colorful keyboard in a dim-lit room](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-HERO-1024x451.jpg.webp)
Creating users with appropriate roles is one of the most important parts of managing a multisite network. Occasionally, you may need to add a user to all sites in the WordPress multisite network.
When that happens, you have 2 options: manually add the same user to every site in the network or use a custom function to automate the process.
Let’s find out how to do both in this step-by-step guide.
How to Add a WordPress Multisite User to All Sites
Method #1: Add a User Manually to All Sites
The first method for adding a user to all sites in a multisite network is manually adding the user to every site.
On the dashboard, go to My Sites > Network Admin > Sites.
![the My Sites menu in the WordPress admin](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-1-1024x451.jpg)
Once on the Sites screen, click on the subdomain to which you plan to add the user.
![Highlighting a site in a multisite network, in the WordPress "Sites" menu](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-2-1024x451.jpg)
On the Edit Site screen, click on the Users tab.
![Highlighting the "Users" tab in WordPress's "Edit Site" menu screen](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-3-1024x451.jpg)
Now, you can add an existing user or create a new one and assign it to this particular site.
In the Add Existing User section, you need to type the username, pick the user’s role, and click Add User.
![The "Add Existing User" menu in WordPress](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-4-1024x451.jpg)
If you instead want to create a new user and add it to the site, scroll down to the Add New User section. Create the username, assign an email address for the user, give it a role, and click on Add New User.
![The "Add New User" menu in WordPress](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-5-1024x451.jpg)
You need to repeat this process on every site in the network if you want to add a user to all sites.
Method #2: Add an Administrator to All Sites With a Function
Adding users manually to every site can be feasible if you manage a handful of sites, but when you manage a large network, the time it takes to add new users becomes significant. Even in smaller networks, going to every site to add multiple users gets old fast.
If you have some coding knowledge, you may benefit from adding a custom function that allows you to enter an email address and turn it into a user on every site in the network.
To programmatically add admin users to all sites in the network, add the following function, created by developer Kevin Leary, to the
file.functions.php
/**
* WPMU Add User to All Sites
*
* Add an administrator user to all sites in a WordPress multisite network
*/
function kevinlearynet_wpmu_add_user_all_sites() {
$email = isset( $_GET['wpmu_admin_sync'] ) ? esc_attr( $_GET['wpmu_admin_sync'] ) : null;
if ( ! $email ) {
return;
}
$user = get_user_by( 'email', $email );
if ( $user === false ) {
wp_die( "No user exists in this network with the email $email." );
}
$role = isset( $user->roles[0] ) ? $user->roles[0] : 'administrator';
$sites = get_sites( [
'limit' => 0,
'public' => true,
'spam' => false,
'deleted' => false,
'archived' => false,
'mature' => false,
] );
$output = [];
foreach ( $sites as $site ) {
$site_id = get_object_vars( $site )['blog_id'];
$site_name = get_blog_details( $site_id )->blogname;
$add_user = add_user_to_blog( $site_id, $user->ID, $role );
$note = "$email user to $site_name as an $role.";
$output[] = $add_user ? "Successfully added $note" : "Failed adding $note";
}
$html = wpautop( implode( PHP_EOL, $output ) );
wp_die( $html );
}
add_action( 'after_setup_theme', 'kevinlearynet_wpmu_add_user_all_sites' );
How to Use the Function?
To use the function, start by visiting your multisite network. Add the following query parameter to your network’s URL:
?wpmu_admin_sync=[user_name_here]@[domain-name_here].com
Here’s an example:
mysite.com/?wpmu_admin_sync=adminuser@mysite.com
Once you’ve added the query parameter with the email address, press Enter. The script will add a new user based on the email address to every site in the network.
![The WordPress interface showing that you've successfully added the admin user new_network_admin@wcanvas.com by using a custom function](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-6-1024x451.jpg)
After running the function, if you go to Sites > All Sites, and click on any of the sites, the go to the Users tab, you should see the newly added admin user.
![WordPress user management interface, showing a newly added user](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-7-1-1024x451.jpg)
Keep in mind that the email address you add must already be associated with an existing user. If you add an email address that isn’t associated with an existing user, you will see this error message.
![The WordPress interface showing that you failed to add a new admin user](https://wcanvas.com/wp-content/uploads/2024/05/wordpress-multisite-add-user-to-all-sites-8-1024x451.jpg)
How Does the Function Work?
This function adds a user by email to all sites in the network. It creates a list of all sites, finds an existing user by mail, and adds it to every site one by one.
The function adds a user with the administrator role by default, so you should modify it to add any other type of user.
Final Thoughts
Managing users is very important in multisite networks. Occasionally, it may be necessary to add a user to every site in the network, but WordPress doesn’t provide a native feature to automatically add the same user to every site.
Your alternatives are to manually add the same user to every site or to use a function that automates the process.
This article provided a step-by-step guide to do both, so now you know what to do next time you have to add a user to every site in your network.
If you found this post useful, read our blog and resources for more WordPress insights and guides!
Related Articles
![someone using a laptop to develop a website](https://wcanvas.com/wp-content/uploads/2024/07/full-site-editor-wordpress-BLOG-ARCHIVE.jpg.webp)
Development / 6 min read
Development / 6 min read
The Benefits of the Full Site Editor for WordPress Users
Full Site Editor (FSE) is a WordPress feature that allows any user to modify their entire site through the familiar interface of the Gutenberg editor. This makes FSE a great…
Read More![](https://wcanvas.com/wp-content/uploads/2024/07/is-wordpress-dying-BLOG-ARCHIVE.jpg.webp)
Development / 14 min read
Development / 14 min read
Is WordPress Dying in 2024?
The question, "Is WordPress dying?" seems to be as old as WordPress itself, but is there any truth to it? If you're considering whether you should use WordPress in 2024…
Read More![The WordPress interface for publishing posts](https://wcanvas.com/wp-content/uploads/2024/07/wordpress-how-to-post-BLOG-ARCHIVE.jpg.webp)
Development / 2 min read
Development / 2 min read
How to Publish Draft Pages in WordPress?
If you’re learning how to use WordPress and wondering how to publish your draft pages or posts, the process is actually really simple, and this article will show you how…
Read More![black alphabetical wall decor](https://wcanvas.com/wp-content/uploads/2024/07/change-font-color-BLOG-ARCHIVE.jpg.webp)
Development / 4 min read
Development / 4 min read
How to Change the Font Color in WordPress: 4 Easy Methods
Are you wondering how to change the font color in your WordPress site? Many people do when looking for a font color that balances readability with brand identity. In this…
Read More![a Mac laptop over a table running the WordPress editor](https://wcanvas.com/wp-content/uploads/2024/07/wordpress-cookie-check-failed-BLOG-ARCHIVE.jpg.webp)
Development / 9 min read
Development / 9 min read
How to Fix the WordPress “Cookie Check Failed” Error
The “cookie check failed” error is a message that appears on some WordPress sites, preventing users from accessing some or all content and admins from managing the website. Let’s explore…
Read More