Skip to content

Commit d0bd37c

Browse files
Copilotswissspidy
andcommitted
Improve wp user remove-role docs and output when no role argument given
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent da791d8 commit d0bd37c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

features/user.feature

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ Feature: Manage WordPress users
352352
| roles | author |
353353
354354
When I run `wp user remove-role 1`
355-
Then STDOUT should not be empty
355+
Then STDOUT should be:
356+
"""
357+
Success: Removed all roles from admin (1).
358+
"""
356359
357360
When I run `wp user get 1`
358361
Then STDOUT should be a table containing rows:

src/User_Command.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,8 @@ public function add_role( $args, $assoc_args ) {
807807
* : User ID, user email, or user login.
808808
*
809809
* [<role>...]
810-
* : Remove the specified role(s) from the user.
810+
* : Remove the specified role(s) from the user. If not passed, all roles are
811+
* removed from the user.
811812
*
812813
* ## EXAMPLES
813814
*
@@ -817,6 +818,9 @@ public function add_role( $args, $assoc_args ) {
817818
* $ wp user remove-role 12 author editor
818819
* Success: Removed 'author', 'editor' roles for johndoe (12).
819820
*
821+
* $ wp user remove-role 12
822+
* Success: Removed all roles from johndoe (12).
823+
*
820824
* @subcommand remove-role
821825
*/
822826
public function remove_role( $args, $assoc_args ) {
@@ -844,7 +848,7 @@ public function remove_role( $args, $assoc_args ) {
844848
$user->remove_all_caps();
845849
}
846850

847-
WP_CLI::success( "Removed {$user->user_login} ({$user->ID}) from " . site_url() . '.' );
851+
WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID})." );
848852
}
849853
}
850854

0 commit comments

Comments
 (0)