You are here

function opigno_module_get_users_by_role in Opigno module 8

Same name and namespace in other branches
  1. 3.x 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 897
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);
}