Get List of Events (Event Manager) with two where condition criteria

I want to extract all the list of event with the following two conditions:

  • time_created should be greater than a selected value
  • It should not below to a list of owner_guid

I have come up with the following code but some how metadata_name_value_pairs is not working as I wanted

$entities_options = [
'type' => 'object',
'subtype' => 'event',
'offset' => 0,
'limit' => 50,
'metadata_name_value_pairs ' => [
                ['name' => 'time_created',
                 'value' => $timestamp,
                 'operand' => '>'],
                ['name' => 'owner_guid',
                 'value' => array("120","121","122"),
                 'operand' => 'NOT IN',

$entities = elgg_get_entities_from_metadata($entities_options);

Please help. Thanks in advance.

  • I found an alternative solution

    $dbprefix = elgg_get_config('dbprefix');
    $event_subtype_id = get_data_row("SELECT `id` from {$dbprefix}entity_subtypes where `subtype`='event'");
    $entities = get_data("SELECT `guid` from {$dbprefix}entities where `type`='object' AND `subtype`={$event_subtype_id->id} AND `owner_guid` NOT IN ($a) AND `time_created` > $last_timestamp");
    foreach($entities as $events){
       ​$event = get_entity($events->guid);