public function generate( $args, $assoc_args ) {
		global $blog_id;

		$defaults   = [
			'count' => 100,
			'role'  => get_option( 'default_role' ),
		];
		$assoc_args = array_merge( $defaults, $assoc_args );

		$role = $assoc_args['role'];

		if ( ! empty( $role ) ) {
			self::validate_role( $role );
		}

		$user_count = count_users();
		$total      = $user_count['total_users'];
		$limit      = $assoc_args['count'] + $total;

		$format = Utils\get_flag_value( $assoc_args, 'format', 'progress' );

		$notify = false;
		if ( 'progress' === $format ) {
			$notify = Utils\make_progress_bar( 'Generating users', $assoc_args['count'] );
		}

		for ( $index = $total; $index < $limit; $index++ ) {
			$login = "user_{$blog_id}_{$index}";
			$name  = "User {$index}";

			$user_id = wp_insert_user(
				[
					'user_login'   => $login,
					'user_pass'    => $login,
					'nickname'     => $name,
					'display_name' => $name,
					'role'         => $role,
				]
			);

			if ( false === $role ) {
				delete_user_option( $user_id, 'capabilities' );
				delete_user_option( $user_id, 'user_level' );
			}

			if ( 'progress' === $format ) {
				$notify->tick();
			} elseif ( 'ids' === $format ) {
				echo $user_id;
				if ( $index < $limit - 1 ) {
					echo ' ';
				}
			}
		}

		if ( 'progress' === $format ) {
			$notify->finish();
		}
	}
public function generate( $args, $assoc_args ) {
		global $blog_id;

		$defaults   = [
			'count' => 100,
			'role'  => get_option( 'default_role' ),
		];
		$assoc_args = array_merge( $defaults, $assoc_args );

		$role = $assoc_args['role'];

		if ( ! empty( $role ) ) {
			self::validate_role( $role );
		}

		$user_count = count_users();
		$total      = $user_count['total_users'];
		$limit      = $assoc_args['count'] + $total;

		$format = Utils\get_flag_value( $assoc_args, 'format', 'progress' );

		$notify = false;
		if ( 'progress' === $format ) {
			$notify = Utils\make_progress_bar( 'Generating users', $assoc_args['count'] );
		}

		for ( $index = $total; $index < $limit; $index++ ) {
			$login = "user_{$blog_id}_{$index}";
			$name  = "User {$index}";

			$user_id = wp_insert_user(
				[
					'user_login'   => $login,
					'user_pass'    => $login,
					'nickname'     => $name,
					'display_name' => $name,
					'role'         => $role,
				]
			);

			if ( false === $role ) {
				delete_user_option( $user_id, 'capabilities' );
				delete_user_option( $user_id, 'user_level' );
			}

			if ( 'progress' === $format ) {
				$notify->tick();
			} elseif ( 'ids' === $format ) {
				echo $user_id;
				if ( $index < $limit - 1 ) {
					echo ' ';
				}
			}
		}

		if ( 'progress' === $format ) {
			$notify->finish();
		}
	}
public function generate ( $ args , $ assoc_args ) { global $ blog_id ; $ defaults = [ 'count' => 100 , 'role' => get_option ( 'default_role' ) , ] ; $ assoc_args = array_merge ( $ defaults , $ assoc_args ) ; $ role = $ assoc_args [ 'role' ] ; if ( ! empty ( $ role ) ) { self :: validate_role ( $ role ) ; } $ user_count = count_users ( ) ; $ total = $ user_count [ 'total_users' ] ; $ limit = $ assoc_args [ 'count' ] + $ total ; $ format = Utils \ get_flag_value ( $ assoc_args , 'format' , 'progress' ) ; $ notify = false ; if ( 'progress' === $ format ) { $ notify = Utils \ make_progress_bar ( 'Generating users' , $ assoc_args [ 'count' ] ) ; } for ( $ index = $ total ; $ index < $ limit ; $ index ++ ) { $ login = "user_{$blog_id}_{$index}" ; $ name = "User {$index}" ; $ user_id = wp_insert_user ( [ 'user_login' => $ login , 'user_pass' => $ login , 'nickname' => $ name , 'display_name' => $ name , 'role' => $ role , ] ) ; if ( false === $ role ) { delete_user_option ( $ user_id , 'capabilities' ) ; delete_user_option ( $ user_id , 'user_level' ) ; } if ( 'progress' === $ format ) { $ notify -> tick ( ) ; } elseif ( 'ids' === $ format ) { echo $ user_id ; if ( $ index < $ limit - 1 ) { echo ' ' ; } } } if ( 'progress' === $ format ) { $ notify -> finish ( ) ; } }
Generates some users.

Creates a specified number of new users with dummy data.

## OPTIONS

[--count=<number>]
: How many users to generate?
---
default: 100
---

[--role=<role>]
: The role of the generated users. Default: default role from WP

[--format=<format>]
: Render output in a particular format.
---
default: progress
options:
- progress
- ids
---

## EXAMPLES

# Add meta to every generated users.
$ wp user generate --format=ids --count=3 | xargs -d ' ' -I % wp user meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.
Generates some users .