Skip to content

Commit dcbf451

Browse files
Issue #34: Allow to get users with no role
1 parent 9fe05e8 commit dcbf451

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/User_Command.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,17 @@ public function list_( $args, $assoc_args ) {
162162

163163
$assoc_args['count_total'] = false;
164164
$assoc_args = self::process_csv_arguments_to_arrays( $assoc_args );
165-
$users = get_users( $assoc_args );
165+
166+
if ( ! empty( $assoc_args['role'] ) && 'none' === $assoc_args['role'] ) {
167+
$norole_user_ids = wp_get_users_with_no_role();
168+
169+
if ( ! empty( $norole_user_ids ) ) {
170+
$assoc_args['include'] = $norole_user_ids;
171+
unset($assoc_args['role']);
172+
}
173+
}
174+
175+
$users = get_users( $assoc_args );
166176

167177
if ( 'ids' === $formatter->format ) {
168178
echo implode( ' ', $users );

0 commit comments

Comments
 (0)