List users which have a given role

@param string $role Role to get users for

@return array List of userIds
558616
public static function getRoleUsers($role)
    {
        global $PPHP;
        $db = $PPHP['db'];

        $out = $db->selectList(
            "
            SELECT userId FROM users_roles
            WHERE role=?
            ORDER BY userId ASC
            ",
            array($role)
        );
        return (is_array($out) ? $out : array());
    }
1196151
public function syncRoles($roles)
    {
        $sync = [];
        $this->mapArray($roles, function ($role) use (&$sync) {

            $sync[] = $this->parseRoleId($role);

            return $sync;
        });

        return $this->roles()->sync($sync);
    }
1193664
public function iAmLoggedInAsRole(string $role)
    {
        $found_user = null;
        $users      = $this->getWordpressParameter('users');

        foreach ($users as $user) {
            if (in_array($role, $user['roles'], true)) {
                $found_user = $user;
                break;
            }
        }

        if ($found_user === null) {
            throw new RuntimeException("[W801] User not found for role \"{$role}\"");
        }

        $this->logIn($found_user['username'], $found_user['password']);
    }
1121908
public function giveUserRole($user, $role)
    {
        $user   =   $this->findUserById($user);
        $role   =   $this->findRoleByKey($role);

        if ($user->is($role->key)) {
            return true;
        }
        
        return $user->join($role);
    }
977645
protected function get_roles( $roles ) {
		if ( empty($roles) ) {
			// @codeCoverageIgnoreStart
			return null;
			// @codeCoverageIgnoreEnd
		}

		$wp_roles = wp_roles();
		$names    = $wp_roles->get_names();

		$values = array();

		foreach ( $roles as $role ) {
			$name = $role;
			if ( isset($names[ $role ]) ) {
				$name = translate_user_role($names[ $role ]);
			}
			$values[ $role ] = $name;
		}

		return $values;
	}
705823
public function findUserIdsInRoles($roleNames)
    {
        $qb = $this->createQueryBuilder('user')
            ->select('DISTINCT(user.id) as id')
            ->leftJoin('user.roles', 'roles')
            ->andWhere('roles.name IN (:roleNames)')
            ->andWhere('user.isRemoved = false')
            ->setParameter('roleNames', $roleNames);
        $query = $qb->getQuery();

        return array_column($query->getScalarResult(), 'id');
    }
429895
private function getAbilities($role)
    {
        $abilities = [];
        foreach (config('auth.acl') as $ability => $roles) {
            if (in_array($role, $roles)) {
                $abilities[] = $ability;
            }
        }

        return $abilities;
    }
276113
public static function getServerListByRoles(array $roles)
    {
        $servers = [];
        foreach ($roles as $roleCode) {
            $rolesForCode = RoleManager::getServersByRole($roleCode);

            foreach ($rolesForCode as $serverCode) {
                if (in_array($serverCode, $servers, true)) {
                    continue;
                }

                $servers[] = $serverCode;
            }
        }

        return $servers;
    }
229756
public function hasRole($role)
    {
        $role = strtoupper($role);

        if ($role == 'ROLE_USER') {
            return true;
        }

        if (in_array($role, $this->roles)) {
            return true;
        }

        return false;
    }
582395
public function getSubRoles(Role $role) {
		
		$parentName = $role->getRoleName();
		$subRoles = [];
		
		if(array_key_exists($role->getRoleName(), $this->mappedRoleNames)) {
			
			foreach($this->mappedRoleNames[$parentName] as $subRoleName) {
				$subRoles[] = new Role($subRoleName);
			}
			
		}
		
		return $subRoles;

	}
642464
public function hasRole($role)
    {
        if (!$this->roles->where('token', $role)->isEmpty()) {
            return true;
        }

        foreach ($this->groups as $group) {
            if (!$group->roles->where('token', $role)->isEmpty()) {
                return true;
            }
        }

        return false;
    }
194407
public function getAuthRoleName($role = null) {
		$role = (int)$role;
		$result = '';
		if ($role === 0) {
			return $result;
		}

		$roleNames = $this->_getAuthFieldsList('name');
		if (empty($roleNames)) {
			return $result;
		}

		if (!krsort($roleNames)) {
			return $result;
		}

		foreach ($roleNames as $roleMask => $roleName) {
			if (($role & $roleMask) === $roleMask) {
				$result = $roleName;
				break;
			}
		}

		return $result;
	}
936342
public function isUserInRole(String $role)
    {

        // query whether or not we've an user principal
        if ($principal = $this->getUserPrincipal()) {
            return $principal->getRoles()->contains($role);
        }

        // user is not in passed role
        return false;
    }
1281147
public function addRole($role)
    {
        $role = strtoupper($role);
        if (static::ROLE_DEFAULT === $role) {
            return $this;
        }

        if (!$this->hasRole($role)) {
            $this->roles[] = $role;
        }

        return $this;
    }
1290240
public function hasRole($role)
    {
        $roles = $this->roles;
        foreach ($roles as $role_obj)
            if ($this->checkRole($role, $role_obj))
                return true;

        return false;
    }
1261388
public function countUsersByRole($role, $restrictionRoleNames)
    {
        $qb = $this->createQueryBuilder('user')
            ->select('COUNT(DISTINCT user.id)')
            ->leftJoin('user.roles', 'roles')
            ->andWhere('roles.id = :roleId')
            ->setParameter('roleId', $role->getId());
        if (!empty($restrictionRoleNames)) {
            $qb->andWhere('user.id NOT IN (:userIds)')
                ->setParameter('userIds', $this->findUserIdsInRoles($restrictionRoleNames));
        }
        $query = $qb->getQuery();

        return $query->getSingleScalarResult();
    }
50828
public function permissions(Role $role)
    {
        $this->authorize('manage_permissions', Role::class);

        return view('laralum_roles::permissions', ['permissions' => Permission::all(), 'role' => $role]);
    }