public function list_( $args, $assoc_args ) {

		if ( Utils\get_flag_value( $assoc_args, 'network' ) ) {
			if ( ! is_multisite() ) {
				WP_CLI::error( 'This is not a multisite installation.' );
			}
			$assoc_args['blog_id'] = 0;
			if ( isset( $assoc_args['fields'] ) ) {
				$fields               = explode( ',', $assoc_args['fields'] );
				$assoc_args['fields'] = array_diff( $fields, [ 'roles' ] );
			} else {
				$assoc_args['fields'] = array_diff( $this->obj_fields, [ 'roles' ] );
			}
		}

		$formatter = $this->get_formatter( $assoc_args );

		if ( in_array( $formatter->format, [ 'ids', 'count' ], true ) ) {
			$assoc_args['fields'] = 'ids';
		} else {
			$assoc_args['fields'] = 'all_with_meta';
		}

		$assoc_args['count_total'] = false;
		$assoc_args                = self::process_csv_arguments_to_arrays( $assoc_args );
		$users                     = get_users( $assoc_args );

		if ( 'ids' === $formatter->format ) {
			echo implode( ' ', $users );
		} elseif ( 'count' === $formatter->format ) {
			$formatter->display_items( $users );
		} else {
			$iterator = Utils\iterator_map(
				$users,
				function ( $user ) {
					if ( ! is_object( $user ) ) {
						return $user;
					}

					$user->roles = implode( ',', $user->roles );
					$user->url   = get_author_posts_url( $user->ID, $user->user_nicename );
					return $user;
				}
			);

			$formatter->display_items( $iterator );
		}
	}
public function list_( $args, $assoc_args ) {

		if ( Utils\get_flag_value( $assoc_args, 'network' ) ) {
			if ( ! is_multisite() ) {
				WP_CLI::error( 'This is not a multisite installation.' );
			}
			$assoc_args['blog_id'] = 0;
			if ( isset( $assoc_args['fields'] ) ) {
				$fields               = explode( ',', $assoc_args['fields'] );
				$assoc_args['fields'] = array_diff( $fields, [ 'roles' ] );
			} else {
				$assoc_args['fields'] = array_diff( $this->obj_fields, [ 'roles' ] );
			}
		}

		$formatter = $this->get_formatter( $assoc_args );

		if ( in_array( $formatter->format, [ 'ids', 'count' ], true ) ) {
			$assoc_args['fields'] = 'ids';
		} else {
			$assoc_args['fields'] = 'all_with_meta';
		}

		$assoc_args['count_total'] = false;
		$assoc_args                = self::process_csv_arguments_to_arrays( $assoc_args );
		$users                     = get_users( $assoc_args );

		if ( 'ids' === $formatter->format ) {
			echo implode( ' ', $users );
		} elseif ( 'count' === $formatter->format ) {
			$formatter->display_items( $users );
		} else {
			$iterator = Utils\iterator_map(
				$users,
				function ( $user ) {
					if ( ! is_object( $user ) ) {
						return $user;
					}

					$user->roles = implode( ',', $user->roles );
					$user->url   = get_author_posts_url( $user->ID, $user->user_nicename );
					return $user;
				}
			);

			$formatter->display_items( $iterator );
		}
	}
public function list_ ( $ args , $ assoc_args ) { if ( Utils \ get_flag_value ( $ assoc_args , 'network' ) ) { if ( ! is_multisite ( ) ) { WP_CLI :: error ( 'This is not a multisite installation.' ) ; } $ assoc_args [ 'blog_id' ] = 0 ; if ( isset ( $ assoc_args [ 'fields' ] ) ) { $ fields = explode ( ',' , $ assoc_args [ 'fields' ] ) ; $ assoc_args [ 'fields' ] = array_diff ( $ fields , [ 'roles' ] ) ; } else { $ assoc_args [ 'fields' ] = array_diff ( $ this -> obj_fields , [ 'roles' ] ) ; } } $ formatter = $ this -> get_formatter ( $ assoc_args ) ; if ( in_array ( $ formatter -> format , [ 'ids' , 'count' ] , true ) ) { $ assoc_args [ 'fields' ] = 'ids' ; } else { $ assoc_args [ 'fields' ] = 'all_with_meta' ; } $ assoc_args [ 'count_total' ] = false ; $ assoc_args = self :: process_csv_arguments_to_arrays ( $ assoc_args ) ; $ users = get_users ( $ assoc_args ) ; if ( 'ids' === $ formatter -> format ) { echo implode ( ' ' , $ users ) ; } elseif ( 'count' === $ formatter -> format ) { $ formatter -> display_items ( $ users ) ; } else { $ iterator = Utils \ iterator_map ( $ users , function ( $ user ) { if ( ! is_object ( $ user ) ) { return $ user ; } $ user -> roles = implode ( ',' , $ user -> roles ) ; $ user -> url = get_author_posts_url ( $ user -> ID , $ user -> user_nicename ) ; return $ user ; } ) ; $ formatter -> display_items ( $ iterator ) ; } }
Lists users.

Display WordPress users based on all arguments supported by
[WP_User_Query()](https://developer.wordpress.org/reference/classes/wp_user_query/prepare_query/).

## OPTIONS

[--role=<role>]
: Only display users with a certain role.

[--<field>=<value>]
: Control output by one or more arguments of WP_User_Query().

[--network]
: List all users in the network for multisite.

[--field=<field>]
: Prints the value of a single field for each user.

[--fields=<fields>]
: Limit the output to specific object fields.

[--format=<format>]
: Render output in a particular format.
---
default: table
options:
- table
- csv
- ids
- json
- count
- yaml
---

## AVAILABLE FIELDS

These fields will be displayed by default for each user:

* ID
* user_login
* display_name
* user_email
* user_registered
* roles

These fields are optionally available:

* user_pass
* user_nicename
* user_url
* user_activation_key
* user_status
* spam
* deleted
* caps
* cap_key
* allcaps
* filter
* url

## EXAMPLES

# List user IDs
$ wp user list --field=ID
1

# List users with administrator role
$ wp user list --role=administrator --format=csv
ID,user_login,display_name,user_email,user_registered,roles
1,supervisor,supervisor,supervisor@gmail.com,"2016-06-03 04:37:00",administrator

# List users with only given fields
$ wp user list --fields=display_name,user_email --format=json
[{"display_name":"supervisor","user_email":"supervisor@gmail.com"}]

# List users ordered by the 'last_activity' meta value.
$ wp user list --meta_key=last_activity --orderby=meta_value_num

@subcommand list
Lists users .