Get entities from metadata AND access_id public

Hey,

I know how I can get entities from metadata, and I know how I van get entities by access id, but I can figure out how to get them both.
I am trying to get entities that have a certain metadata set to true and are public access.

I tried to be smart and thought access_id was handled in these query as metadata as well, but of course that was too easy, 

$options = array(
    'type' => 'object',
	'subtype' => 'mysubtype',
	'metadata_name_value_pairs' => array(
        array(
		'name' => 'metadataname',
		'value' => true,
	   ),
        array(
		'name' => 'access_id',
		'value' => ACCESS_PUBLIC,
	   )),
    'full_view' => false,
    'limit' => '30',
    'pagination' =>false,
);

$content = elgg_list_entities_from_metadata($options);

Who has an idea, of an example where I can take a look? I searched the core's code to find an example, but can't find any.

Should I first get the metadata entities and then iterate through that array to get the public ones with a second query?

Thanks

  • I haven't tested but something like this should work:

    $options = array(
        'type' => 'object',
        'subtype' => 'mysubtype',
        'metadata_name_value_pairs' => array(
            array(
                'name' => 'metadataname',
                'value' => true,
            ),
        ),
        'wheres' => array('e.access_id = ' . ACCESS_PUBLIC),
        'full_view' => false,
        'limit' => '30',
        'pagination' =>false,
    );
    
    $content = elgg_list_entities_from_metadata($options);
  • Of course!

    Thanks! I'm building something nice with your featured plugin as a base :)