Get all of users who has role's admin in the group

Public

return all of uids of user who has role's admin

Get raw version
php
  1. function _get_all_admin_group($gid) {
  2. $uids = array();
  3. $role_admin = array('administrator member', 'moderator');
  4.  
  5. $query = db_select('og_users_roles', 'ogur');
  6. $query->innerJoin('og_role', 'ogr', 'ogur.rid = ogr.rid');
  7.  
  8. $rids = $query
  9. ->fields('ogur', array('uid'))
  10. ->condition('ogur.gid', $gid, '=')
  11. ->condition('ogr.name', $role_admin, 'IN')
  12. ->execute();
  13.  
  14. foreach ($rids as $item) {
  15. $uids[] = $item->uid;
  16. }
  17.  
  18. return $uids;
  19. }