get_role

Retrieve role object.

Description

(WP_Role|null) get_role( (string) $role ); 

Returns (WP_Role|null)

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

Parameters (1)

0. $role (string)
Role name.

Usage

  1. if ( !function_exists( 'get_role' ) ) { 
  2. require_once ABSPATH . WPINC . '/capabilities.php'; 
  3.  
  4. // Role name. 
  5. $role = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_role($role); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/capabilities.php  
  1. function get_role( $role ) { 
  2. returnwp_roles)->get_role( $role );