From da791d8248a93f37c68f6234f1452b038db32699 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 09:18:56 +0000 Subject: [PATCH 1/5] Initial plan From d0bd37cbb06de099858b633c89ad87d4a679659f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 09:21:59 +0000 Subject: [PATCH 2/5] Improve wp user remove-role docs and output when no role argument given Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/user.feature | 5 ++++- src/User_Command.php | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/features/user.feature b/features/user.feature index 4f8640e14..0aeb73945 100644 --- a/features/user.feature +++ b/features/user.feature @@ -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 be: + """ + Success: Removed all roles from admin (1). + """ When I run `wp user get 1` Then STDOUT should be a table containing rows: diff --git a/src/User_Command.php b/src/User_Command.php index 7d7c68959..de20d3414 100644 --- a/src/User_Command.php +++ b/src/User_Command.php @@ -807,7 +807,8 @@ public function add_role( $args, $assoc_args ) { * : User ID, user email, or user login. * * [...] - * : 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. * * ## EXAMPLES * @@ -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). + * * @subcommand remove-role */ public function remove_role( $args, $assoc_args ) { @@ -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})." ); } } From 32ef6e9acb94f857c112f82c226fb818c829b7d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 09:48:23 +0000 Subject: [PATCH 3/5] Include site URL in remove-role success message when no role given Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/user.feature | 4 ++-- src/User_Command.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/user.feature b/features/user.feature index 0aeb73945..cd22acdd6 100644 --- a/features/user.feature +++ b/features/user.feature @@ -352,9 +352,9 @@ Feature: Manage WordPress users | roles | author | When I run `wp user remove-role 1` - Then STDOUT should be: + Then STDOUT should contain: """ - Success: Removed all roles from admin (1). + Success: Removed all roles from admin (1) on """ When I run `wp user get 1` diff --git a/src/User_Command.php b/src/User_Command.php index de20d3414..29cd9ae51 100644 --- a/src/User_Command.php +++ b/src/User_Command.php @@ -819,7 +819,7 @@ public function add_role( $args, $assoc_args ) { * Success: Removed 'author', 'editor' roles for johndoe (12). * * $ wp user remove-role 12 - * Success: Removed all roles from johndoe (12). + * Success: Removed all roles from johndoe (12) on http://example.com. * * @subcommand remove-role */ @@ -848,7 +848,7 @@ public function remove_role( $args, $assoc_args ) { $user->remove_all_caps(); } - WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID})." ); + WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID}) on " . site_url() . '.' ); } } From 637482d37fe7b5bb6b8e6e47efc0efbced966b1b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sat, 28 Feb 2026 13:36:29 +0100 Subject: [PATCH 4/5] Update src/User_Command.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/User_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/User_Command.php b/src/User_Command.php index 29cd9ae51..e60eb8500 100644 --- a/src/User_Command.php +++ b/src/User_Command.php @@ -808,8 +808,8 @@ public function add_role( $args, $assoc_args ) { * * [...] * : Remove the specified role(s) from the user. If not passed, all roles are - * removed from the user. - * + * removed from the user; on multisite, this removes the user from the current + * site/blog. * ## EXAMPLES * * $ wp user remove-role 12 author From 8d375bbdaf24d3d2eee6df50b135e54ff670e65c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 08:05:12 +0000 Subject: [PATCH 5/5] Branch remove-role no-arg success message for multisite vs single-site Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/User_Command.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/User_Command.php b/src/User_Command.php index e60eb8500..e0c8654be 100644 --- a/src/User_Command.php +++ b/src/User_Command.php @@ -810,17 +810,23 @@ public function add_role( $args, $assoc_args ) { * : Remove the specified role(s) from the user. If not passed, all roles are * removed from the user; on multisite, this removes the user from the current * site/blog. + * * ## EXAMPLES * * $ wp user remove-role 12 author - * Success: Removed 'author' role for johndoe (12). + * Success: Removed 'author' role from johndoe (12). * * $ wp user remove-role 12 author editor - * Success: Removed 'author', 'editor' roles for johndoe (12). + * Success: Removed 'author', 'editor' roles from johndoe (12). * + * # On single-site: removes all roles from the user * $ wp user remove-role 12 * Success: Removed all roles from johndoe (12) on http://example.com. * + * # On multisite: removes the user from the current site/blog + * $ wp user remove-role 12 + * Success: Removed johndoe (12) from http://example.com. + * * @subcommand remove-role */ public function remove_role( $args, $assoc_args ) { @@ -841,14 +847,14 @@ public function remove_role( $args, $assoc_args ) { $label = count( $roles ) > 1 ? 'roles' : 'role'; WP_CLI::success( "Removed '{$message}' {$label} from {$user->user_login} ({$user->ID})." ); } else { - // Multisite + $site_url = site_url(); if ( function_exists( 'remove_user_from_blog' ) ) { remove_user_from_blog( $user->ID, get_current_blog_id() ); + WP_CLI::success( "Removed {$user->user_login} ({$user->ID}) from {$site_url}." ); } else { $user->remove_all_caps(); + WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID}) on {$site_url}." ); } - - WP_CLI::success( "Removed all roles from {$user->user_login} ({$user->ID}) on " . site_url() . '.' ); } }