Skip to content

Commit 8d375bb

Browse files
Copilotswissspidy
andcommitted
Branch remove-role no-arg success message for multisite vs single-site
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 637482d commit 8d375bb

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/User_Command.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,17 +810,23 @@ public function add_role( $args, $assoc_args ) {
810810
* : Remove the specified role(s) from the user. If not passed, all roles are
811811
* removed from the user; on multisite, this removes the user from the current
812812
* site/blog.
813+
*
813814
* ## EXAMPLES
814815
*
815816
* $ wp user remove-role 12 author
816-
* Success: Removed 'author' role for johndoe (12).
817+
* Success: Removed 'author' role from johndoe (12).
817818
*
818819
* $ wp user remove-role 12 author editor
819-
* Success: Removed 'author', 'editor' roles for johndoe (12).
820+
* Success: Removed 'author', 'editor' roles from johndoe (12).
820821
*
822+
* # On single-site: removes all roles from the user
821823
* $ wp user remove-role 12
822824
* Success: Removed all roles from johndoe (12) on http://example.com.
823825
*
826+
* # On multisite: removes the user from the current site/blog
827+
* $ wp user remove-role 12
828+
* Success: Removed johndoe (12) from http://example.com.
829+
*
824830
* @subcommand remove-role
825831
*/
826832
public function remove_role( $args, $assoc_args ) {
@@ -841,14 +847,14 @@ public function remove_role( $args, $assoc_args ) {
841847
$label = count( $roles ) > 1 ? 'roles' : 'role';
842848
WP_CLI::success( "Removed '{$message}' {$label} from {$user->user_login} ({$user->ID})." );
843849
} else {
844-
// Multisite
850+
$site_url = site_url();
845851
if ( function_exists( 'remove_user_from_blog' ) ) {
846852
remove_user_from_blog( $user->ID, get_current_blog_id() );
853+
WP_CLI::success( "Removed {$user->user_login} ({$user->ID}) from {$site_url}." );
847854
} else {
848855
$user->remove_all_caps();
856+
WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID}) on {$site_url}." );
849857
}
850-
851-
WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID}) on " . site_url() . '.' );
852858
}
853859
}
854860

0 commit comments

Comments
 (0)