You are here

function opigno_module_get_users_by_role in Opigno module 3.x

Same name and namespace in other branches
  1. 8 opigno_module.module \opigno_module_get_users_by_role()

Function for loading all users by role.

1 call to opigno_module_get_users_by_role()
OpignoModuleController::userResult in src/Controller/OpignoModuleController.php
Returns user result.

File

./opigno_module.module, line 896
Contains opigno_module.module.

Code

function opigno_module_get_users_by_role($role) {
  if (!is_string($role)) {
    return FALSE;
  }
  $user_storage = \Drupal::service('entity_type.manager')
    ->getStorage('user');
  $ids = $user_storage
    ->getQuery()
    ->condition('status', 1)
    ->condition('roles', $role)
    ->execute();
  return $user_storage
    ->loadMultiple($ids);
}