public function set_role( $args, $assoc_args ) {
		$user = $this->fetcher->get_check( $args[0] );

		$role = Utils\get_flag_value( $args, 1, get_option( 'default_role' ) );

		self::validate_role( $role );

		// Multisite
		if ( function_exists( 'add_user_to_blog' ) ) {
			add_user_to_blog( get_current_blog_id(), $user->ID, $role );
		} else {
			$user->set_role( $role );
		}

		WP_CLI::success( "Added {$user->user_login} ({$user->ID}) to " . site_url() . " as {$role}." );
	}
public function set_role( $args, $assoc_args ) {
		$user = $this->fetcher->get_check( $args[0] );

		$role = Utils\get_flag_value( $args, 1, get_option( 'default_role' ) );

		self::validate_role( $role );

		// Multisite
		if ( function_exists( 'add_user_to_blog' ) ) {
			add_user_to_blog( get_current_blog_id(), $user->ID, $role );
		} else {
			$user->set_role( $role );
		}

		WP_CLI::success( "Added {$user->user_login} ({$user->ID}) to " . site_url() . " as {$role}." );
	}
public function set_role ( $ args , $ assoc_args ) { $ user = $ this -> fetcher -> get_check ( $ args [ 0 ] ) ; $ role = Utils \ get_flag_value ( $ args , 1 , get_option ( 'default_role' ) ) ; self :: validate_role ( $ role ) ; // Multisite if ( function_exists ( 'add_user_to_blog' ) ) { add_user_to_blog ( get_current_blog_id ( ) , $ user -> ID , $ role ) ; } else { $ user -> set_role ( $ role ) ; } WP_CLI :: success ( "Added {$user->user_login} ({$user->ID}) to " . site_url ( ) . " as {$role}." ) ; }
Sets the user role.

## OPTIONS

<user>
: User ID, user email, or user login.

[<role>]
: Make the user have the specified role. If not passed, the default role is
used.

## EXAMPLES

$ wp user set-role 12 author
Success: Added johndoe (12) to http://example.com as author.

@subcommand set-role
Sets the user role .