function user_role_names

Retrieve an array of roles matching specified conditions.

Parameters

$membersonly: Set this to TRUE to exclude the 'anonymous' role.

$permission: A string containing a permission. If set, only roles containing that permission are returned.

Return value

An associative array with the role id as the key and the role name as value.

17 calls to user_role_names()
AccountFormController::form in drupal/core/modules/user/lib/Drupal/user/AccountFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
AccountSettingsForm::buildForm in drupal/core/modules/user/lib/Drupal/user/AccountSettingsForm.php
Implements \Drupal\Core\Form\FormInterface::buildForm().
BlockFormController::form in drupal/core/modules/block/lib/Drupal/block/BlockFormController.php
Overrides \Drupal\Core\Entity\EntityFormController::form().
BulkFormTest::testBulkForm in drupal/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php
Tests the user bulk form.
ChangeUserRoleBase::form in drupal/core/modules/user/lib/Drupal/user/Plugin/Action/ChangeUserRoleBase.php
Form constructor.

... See full list

File

drupal/core/modules/user/user.module, line 1764
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));
}