function user_role_names
Same name in other branches
- 9 core/modules/user/user.module \user_role_names()
- 10 core/modules/user/user.module \user_role_names()
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.
17 calls to user_role_names()
- AccountForm::form in core/
modules/ user/ src/ AccountForm.php - Gets the actual form array to be built.
- AccountSettingsForm::buildForm in core/
modules/ user/ src/ AccountSettingsForm.php - Form constructor.
- BulkFormTest::testBulkForm in core/
modules/ user/ tests/ src/ Functional/ Views/ BulkFormTest.php - Tests the user bulk form.
- ChangeUserRoleBase::buildConfigurationForm in core/
modules/ user/ src/ Plugin/ Action/ ChangeUserRoleBase.php - Form constructor.
- FilterFormatAccessTest::testFormatRoles in core/
modules/ filter/ tests/ src/ Functional/ FilterFormatAccessTest.php - Tests if text format is available to a role.
File
-
core/
modules/ user/ user.module, line 1062
Code
function user_role_names($membersonly = FALSE, $permission = NULL) {
return array_map(function ($item) {
return $item->label();
}, user_roles($membersonly, $permission));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.