WordPress at Your Fingertips
function is not described

WP_Users_List_Table::get_role_list() protected WP 4.4.0

Returns an array of user roles for a given user object.

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

Hooks from the method

Return

String[]. An array of user roles.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_role_list( $user_object );
$user_object(WP_User) (required)
The WP_User object.

Changelog

Since 4.4.0 Introduced.

Code of WP_Users_List_Table::get_role_list() WP 5.8.2

protected function get_role_list( $user_object ) {
	$wp_roles = wp_roles();

	$role_list = array();

	foreach ( $user_object->roles as $role ) {
		if ( isset( $wp_roles->role_names[ $role ] ) ) {
			$role_list[ $role ] = translate_user_role( $wp_roles->role_names[ $role ] );
		}
	}

	if ( empty( $role_list ) ) {
		$role_list['none'] = _x( 'None', 'no user roles' );
	}

	/**
	 * Filters the returned array of roles for a user.
	 *
	 * @since 4.4.0
	 *
	 * @param string[] $role_list   An array of user roles.
	 * @param WP_User  $user_object A WP_User object.
	 */
	return apply_filters( 'get_role_list', $role_list, $user_object );
}