WordPress Multisite simplifies managing multiple WordPress sites from a single installation. With the help of wp-cli, the command-line interface for WordPress, user management across your multisite network becomes even more efficient. Let's explore how you can create, add, and delete users seamlessly using wp-cli.

Creating a User
To create a user in your WordPress Multisite network, use the following command:

wp user create my_username my@email.com --url=multisite-domain.com --role=administrator

Replace my_username and my@email.com with the desired username and email address, respectively. Additionally, specify the URL of your Multisite network using the --url flag, and assign a role to the user using the --role flag.

Adding a User to a Site
Once a user is created, you can add them to a specific site within your Multisite network using the wp user update command:

wp user update my_username --url=other-multisite.com --role=administator

Replace my_username with the username of the user you want to add, specify the URL of the site using the --url flag, and assign a role to the user using the --role flag.

Example: Adding User to a Specific Site
Suppose we have a Multisite network with a site located at subdonmain.example.com, and we want to add a user named user-name as an administrator to this site. We would use the following command:

wp user update user-name --url=red-subdonmain.example.com --role=administator

Managing Users

Adding a User with Specific Role
You can also create a user with a specific role using wp-cli. For example, to create a subscriber named dynamicTester with the email dynamicTest@test.com and password 12345, you would execute:

wp user create dynamicTester dynamicTest@test.com --role=subscriber --user_pass=12345

Deleting a User
To delete a user from your Multisite network, use the wp user delete command. For instance, to delete the user with the email test@test.com from the entire network, you would run:

wp user delete test@test.com --network

Conclusion
With wp-cli, managing users in your WordPress Multisite network becomes a straightforward task. Whether you're creating new users, adding them to specific sites, or removing them from the network altogether, wp-cli offers a convenient and efficient solution for user management.