Get entities by metadata in Elgg 3.X

In Elgg 3.X how do you get entites based on metadata values.

Lets say my entitities are made like the following:

$object = new ElggObject();
$object->subtype = "user_status";
$object->status = "active;
$object->count = 5;
$object->approved = "yes";
$object->access_id = 2;
$object->save();

I only want to get entities based on the following logic.

count > 3

status = "notactive"

approved = "yes"

How would this be done?

  • $matching_entities = elgg_get_entities([
        'type' => 'object',
        'subtype' => 'user_status',
        'metadata_name_value_pairs' => [
            [
                'name' => 'status',
                'value' => 'notactive',
                'operand' => '=',
            ],
            [
                'name' => 'approved',
                'value' => 'yes',
                'operand' => '=',
            ],
            [
                'name' => 'count',
                'value' => '3',
                'operand' => '>',
            ],
        ],
    ]);
  • This works flawless, thank you iionly!