Skip to content

Commit 06763ac

Browse files
committed
Display user ID instead of user_login
1 parent 66786b5 commit 06763ac

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

features/super-admin.feature

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ Feature: Manage super admins associated with a multisite instance
2424
superadmin
2525
"""
2626

27-
When I run `wp super-admin list --format=ids`
28-
Then STDOUT should be:
29-
"""
30-
admin superadmin
31-
"""
32-
3327
When I try `wp super-admin add superadmin`
3428
Then STDERR should be:
3529
"""
@@ -186,6 +180,22 @@ Feature: Manage super admins associated with a multisite instance
186180
And STDOUT should be empty
187181
And the return code should be 1
188182

183+
Scenario: List super admins in ids format.
184+
Given a WP multisite installation
185+
186+
When I run `wp user get admin --field=ID`
187+
And save STDOUT as {USER_1}
188+
189+
When I run `wp user create admin2 admin2@example.com --porcelain`
190+
And save STDOUT as {USER_2}
191+
192+
When I run `wp super-admin add admin2`
193+
And I run `wp super-admin list --format=ids`
194+
Then STDOUT should be:
195+
"""
196+
{USER_1} {USER_2}
197+
"""
198+
189199
Scenario: Manage a super admin user_login 'admin'
190200
Given a WP multisite installation
191201

src/Super_Admin_Command.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ public function list_subcommand( $_, $assoc_args ) {
8181

8282
if ( ! empty( $assoc_args['format'] ) && 'ids' === $assoc_args['format'] ) {
8383
$formatter = new \WP_CLI\Formatter( $assoc_args );
84-
$formatter->display_items( wp_list_pluck( $output_users, 'user_login' ) );
84+
85+
$user_ids = [];
86+
foreach ( $super_admins as $user_login ) {
87+
$user_obj = get_user_by( 'login', $user_login );
88+
$user_ids[] = $user_obj->ID;
89+
}
90+
$formatter->display_items( $user_ids );
8591
} else {
8692
$formatter = new \WP_CLI\Formatter( $assoc_args, $this->fields );
8793
$formatter->display_items( $output_users );

0 commit comments

Comments
 (0)