WP-CLI can change a WordPress user’s role from a terminal. A role determines what that user can do, so confirm the site and account before granting or removing access.
Identify the user and role
Connect as the site’s system account and change to the actual WordPress installation directory. Do not run site-management commands as root.
List users and available roles:
wp user list --fields=ID,user_login,roles
wp role listRecord the user’s current role so you can restore it if needed.
Set the new role
For example, to replace user 3’s role with Editor:
wp user set-role 3 editorReplace the example ID and role with the verified values. This sets the role rather than simply adding another one; use a supported add-role operation only when multiple roles are deliberate.
Verify access
Check the resulting user:
wp user get 3 --field=rolesTest the expected permissions. Avoid removing the site’s only working administrator or granting Administrator when a narrower role is sufficient.
For a multisite network, specify the intended site with --url=https://example.com. A site’s Administrator role is different from network Super Admin access.