Get memebers from group with display?

If you check the groups on the side you'll see all your members :P

This includes members with default pictures that look 'default' xD

I've been playing around with the default getMembers() but I've been looking for a way to only fliter those members that have a beautiful picture. Is there a simple way to doing this?

  • get by metadata "icontime". Those who have not uploaded a profile icon will not appear.

  • yuppers I tried that :P unfortunately it also pulls members that are not part of the group itself xDddd any ideas? :P?

  • This is a bit tricky, as you need to filter your results both by metadata (icontime, as Trajan said) and by relationship (member of the given group). Elgg does not have a built in function for that. You can either

    a) get all group members, iterate through them and check for $user->icontime, only displaying those who have a bigger than zero value

    $users_with_icons = array();
    $count = $group->getMembers(10, 0, true);
    $members = $group->getMembers($count);
    foreach($members as $member) {
        if ($member->icontime > 0) {
            $users_with_icons[] = $member;
        }
    }

    b) add custom join and where tags to your query options, that would go something like this:

    global $CONFIG;
    $options = array(
        "type" => "user",
        "limit" => 10,
        "metadata_name_value_pairs" => array(array("name" => "icontime", "operand" => ">", value => 0)),
        "joins" => array(
            "INNER JOIN {$CONFIG->dbprefix}entity_relationships r ON (r.relationship = 'member' AND r.guid_one = e.guid)"
            "INNER JOIN {$CONFIG->dbprefix}groups_entity g ON (g.guid = r.guid_two)"
        ),
        "wheres" => array("g.guid = $group_guid")
    );
    $users = elgg_get_entities_from_metadata($options);

    First approach is easier and safer (uses only Elgg API functions), second is faster (but not 100% future proof, as relies on database table references).