WordPress at Your Fingertips
function is not described

WP_Roles::get_role() public WP 2.0.0

Retrieve role object by name.

{} It's a method of the class: WP_Roles{}

No Hooks.


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


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

Code of WP_Roles::get_role() WP 5.8.3

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