WP_Roles::get_role( string $role )

Retrieve role object by name.

Parameters

$role

(string) (Required) Role name.

Return

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

Source

File: wp-includes/class-wp-roles.php

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

Changelog

Version Description
2.0.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_roles/get_role