WP_Roles::get_rolepublicWP 2.0.0

Retrieves a role object by name.

Method of the class: WP_Roles{}

No Hooks.

Returns

WP_Role|null. WP_Role object if found, null if the role does not exist.

Usage

global $wp_roles;
$wp_roles->get_role( $role );
$role(string) (required)
Role name.

Changelog

Since 2.0.0 Introduced.

WP_Roles::get_role() code WP 7.0

public function get_role( $role ) {
	return $this->role_objects[ $role ] ?? null;
}