File tree Expand file tree Collapse file tree 2 files changed +8
-17
lines changed
Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -254,16 +254,7 @@ Feature: Manage super admins associated with a multisite instance
254254 """
255255
256256 When I run `wp user create superadmin superadmin@example.com`
257- Then STDOUT should contain:
258- """
259- grant_super_admin hook was fired.
260- """
261- And STDOUT should contain:
262- """
263- granted_super_admin hook was fired.
264- """
265-
266- When I run `wp super-admin add superadmin`
257+ And I run `wp super-admin add superadmin`
267258 Then STDOUT should contain:
268259 """
269260 grant_super_admin hook was fired.
@@ -294,7 +285,7 @@ Feature: Manage super admins associated with a multisite instance
294285 """
295286
296287 When I try `wp super-admin add noadmin`
297- Then STDOUT should contain:
288+ Then STDOUT should not contain:
298289 """
299290 grant_super_admin hook was fired.
300291 """
@@ -314,7 +305,7 @@ Feature: Manage super admins associated with a multisite instance
314305 """
315306
316307 When I try `wp super-admin remove noadmin`
317- Then STDOUT should contain:
308+ Then STDOUT should not contain:
318309 """
319310 revoke_super_admin hook was fired.
320311 """
Original file line number Diff line number Diff line change @@ -160,11 +160,6 @@ public function add( $args, $_ ) {
160160 * Success: Revoked super-admin capabilities.
161161 */
162162 public function remove ( $ args , $ _ ) {
163- $ super_admins = self ::get_admins ();
164- if ( ! $ super_admins ) {
165- WP_CLI ::error ( 'No super admins to revoke super-admin privileges from. ' );
166- }
167-
168163 $ users = $ this ->fetcher ->get_many ( $ args );
169164 $ user_logins = $ users ? array_values ( array_unique ( wp_list_pluck ( $ users , 'user_login ' ) ) ) : [];
170165 $ user_logins_count = count ( $ user_logins );
@@ -176,6 +171,11 @@ public function remove( $args, $_ ) {
176171 do_action ( 'revoke_super_admin ' , (int ) $ user ->ID ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
177172 }
178173
174+ $ super_admins = self ::get_admins ();
175+ if ( ! $ super_admins ) {
176+ WP_CLI ::error ( 'No super admins to revoke super-admin privileges from. ' );
177+ }
178+
179179 if ( $ user_logins_count < count ( $ args ) ) {
180180 $ flipped_user_logins = array_flip ( $ user_logins );
181181 // Fetcher has already warned so don't bother here, but continue with any args that are possible login names to cater for invalid users in the site options meta.
You can’t perform that action at this time.
0 commit comments