get_role() WordPress Function

The get_role() function is used to get a role object by its name.

get_role( string $role ) #

Retrieves role object.


Parameters

$role

(string)(Required)Role name.


Top ↑

Return

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


Top ↑

Source

File: wp-includes/capabilities.php

function get_role( $role ) {
	return wp_roles()->get_role( $role );
}


Top ↑

Changelog

Changelog
VersionDescription
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.