function user_role_names
user_role_names($membersonly = FALSE, $permission = NULL)
Retrieves the names of roles matching specified conditions.
Parameters
bool $membersonly: (optional) Set this to TRUE to exclude the 'anonymous' role. Defaults to FALSE.
string|null $permission: (optional) A string containing a permission. If set, only roles containing that permission are returned. Defaults to NULL, which returns all roles.
Return value
array An associative array with the role id as the key and the role name as value.
File
- core/modules/user/user.module, line 971
- Enables the user registration and login system.
Code
function user_role_names($membersonly = FALSE, $permission = NULL) { return array_map(function($item) { return $item->label(); }, user_roles($membersonly, $permission)); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!user!user.module/function/user_role_names/8.1.x