Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion features/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ Feature: Manage WordPress users
| roles | author |

When I run `wp user remove-role 1`
Then STDOUT should not be empty
Then STDOUT should contain:
"""
Success: Removed all roles from admin (1) on
"""

When I run `wp user get 1`
Then STDOUT should be a table containing rows:
Expand Down
8 changes: 6 additions & 2 deletions src/User_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,8 @@ public function add_role( $args, $assoc_args ) {
* : User ID, user email, or user login.
*
* [<role>...]
* : Remove the specified role(s) from the user.
* : Remove the specified role(s) from the user. If not passed, all roles are
* removed from the user.
*
Comment on lines +811 to 812
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc update still omits the multisite nuance called out in the issue context (no role args may remove the user from the site/blog). Please update the synopsis description to mention the multisite behavior explicitly, so users aren’t surprised by being removed from a site when running the command on multisite.

Suggested change
* removed from the user.
*
* removed from the user; on multisite, this removes the user from the current
* site/blog.

Copilot uses AI. Check for mistakes.
* ## EXAMPLES
*
Expand All @@ -817,6 +818,9 @@ public function add_role( $args, $assoc_args ) {
* $ wp user remove-role 12 author editor
* Success: Removed 'author', 'editor' roles for johndoe (12).
*
* $ wp user remove-role 12
* Success: Removed all roles from johndoe (12) on http://example.com.
*
* @subcommand remove-role
*/
public function remove_role( $args, $assoc_args ) {
Expand Down Expand Up @@ -844,7 +848,7 @@ public function remove_role( $args, $assoc_args ) {
$user->remove_all_caps();
}

WP_CLI::success( "Removed {$user->user_login} ({$user->ID}) from " . site_url() . '.' );
WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID}) on " . site_url() . '.' );
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new message is clearer for single-site, but it may be inaccurate on multisite where the no-role path can remove the user from the site/blog (not just strip roles). Consider branching the message for multisite (e.g., explicitly “Removed user from site …” or “Removed all roles (user removed from site on multisite) …”) so the output reflects what actually happened.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

}
}

Expand Down
Loading