WP_Roles::get_role()publicWP 2.0.0

Retrieves a role object by name.

Method of the class: WP_Roles{}

No Hooks.

Return

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 6.1.1

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