src/Role_Command.php
public function exists( $args ) {
		global $wp_roles;

		if ( ! in_array( $args[0], array_keys( $wp_roles->roles ), true ) ) {
			WP_CLI::error( "Role with ID '{$args[0]}' does not exist." );
		}

		WP_CLI::success( "Role with ID '{$args[0]}' exists." );
	}
public function exists( $args ) {
		global $wp_roles;

		if ( ! in_array( $args[0], array_keys( $wp_roles->roles ), true ) ) {
			WP_CLI::error( "Role with ID '{$args[0]}' does not exist." );
		}

		WP_CLI::success( "Role with ID '{$args[0]}' exists." );
	}
public function exists ( $ args ) { global $ wp_roles ; if ( ! in_array ( $ args [ 0 ] , array_keys ( $ wp_roles -> roles ) , true ) ) { WP_CLI :: error ( "Role with ID '{$args[0]}' does not exist." ) ; } WP_CLI :: success ( "Role with ID '{$args[0]}' exists." ) ; }
Checks if a role exists.

Exits with return code 0 if the role exists, 1 if it does not.

## OPTIONS

<role-key>
: The internal name of the role.

## EXAMPLES

# Check if a role exists.
$ wp role exists editor
Success: Role with ID 'editor' exists.
Checks if a role exists .