Add WordPress User to Multisite via WP CLI

Adding a new user to a sub-site of a WordPress multisite is a two step process via the WP CLI.

Add a user to the network

First we’ll add a new user to the multisite network with the following WP CLI command:

wp user create example_username example_email@email.com --first_name=Example --last_name=User --url=multisite-network.com --role=administrator

In this example we’ve assigned the role of administrator, while the other options are editor, author, contributor, and subscriber. The full list of options you can pass to wp user create is available in the official documentation here.

Add user to sub-site

Next we’ll use the wp user update command to add the new user to a sub-site:

wp user update example_username --url=example-sub-site.com --role=administrator

We can repeat this command as needed for adding a user to other sub-sites on the network.

the author profile picture

Ryan Neilson is a software developer from Nova Scotia, Canada, where he lives with his wife and their menagerie of pets. He has worked extensively with PHP, WordPress, JavaScript, React, SCSS and CSS. Ryan can be found professionally at News Corp, where he works as a lead software engineer.