wp user set-role (Multisite Context)
Overview
In a Multisite environment, users exist at the network level but hold specific roles on each subsite. Use this command with the --url flag to assign or change a user's permissions on a particular site.
Syntax
wp user set-role <user> <role> --url=<site-url>
Basic Usage
Make a user a contributor on Subsite A
wp user set-role jane_doe contributor --url=example.com/site-a
Output:
Success: Added jane_doe (15) to http://example.com/site-a/ with role contributor.
Real-World Scenarios
Scenario 1: Bulk updating roles across sites
While you can script this with wp site list, remember that roles only exist per site.
# Set role on a specific subdomain site
wp user set-role dev_user administrator --url=dev.example.com
Common Gotchas
- Missing
--url— If you omit the URL, WP-CLI defaults to the root site. - Super Admin Power — Super admins essentially have
administratorprivileges on every site, even if not explicitly assigned a role via this command.
Next Steps
wp user add-role— assign multiple roles to one user.