Elgg\Database\AccessCollections::getMembers PHP Method

getMembers() public method

Get all of members of an access collection
public getMembers ( integer $collection_id, boolean $guids_only = false ) : ElggUse\ElggUser[] | int[] | false
$collection_id integer The collection's ID
$guids_only boolean If set to true, will only return the members' GUIDs (default: false)
return ElggUse\ElggUser[] | int[] | false guids or entities if successful, false if not
    function getMembers($collection_id, $guids_only = false)
    {
        $collection_id = (int) $collection_id;
        $db = $this->db;
        $prefix = $db->prefix;
        if (!$guids_only) {
            $query = "SELECT e.* FROM {$prefix}access_collection_membership m" . " JOIN {$prefix}entities e ON e.guid = m.user_guid" . " WHERE m.access_collection_id = {$collection_id}";
            $collection_members = $db->getData($query, "entity_row_to_elggstar");
        } else {
            $query = "SELECT e.guid FROM {$prefix}access_collection_membership m" . " JOIN {$prefix}entities e ON e.guid = m.user_guid" . " WHERE m.access_collection_id = {$collection_id}";
            $collection_members = $db->getData($query);
            if (!$collection_members) {
                return false;
            }
            foreach ($collection_members as $key => $val) {
                $collection_members[$key] = $val->guid;
            }
        }
        return $collection_members;
    }