2

If I tag a contact as a Major Donor and a Volunteer, I can retrieve their contact ID via the API using an API call such as:

$result = civicrm_api3('EntityTag', 'get', array(
  'entity_table' => "civicrm_contact",
  'tag_id' => "Volunteer",
));

or

$result = civicrm_api3('EntityTag', 'get', array(
  'entity_table' => "civicrm_contact",
  'tag_id' => "Major Donor",
));

but I want to find only contacts who have both tags, I have to resort to making two API calls and comparing the results.

This seems to be the case across various CiviCRM APIs. For example, it doesn't seem to be possible to make an API call to retrieve groups that are of type ACL and Mailing List. Am I missing something? Have folks developed a recipe for this kind of query?

1

You can achieve this by giving the key 'tag_id' an array containing multiple tags. Something like this:

'tag_id' => array('volunteer', 'Major Donor'),

  • This returns an empty result. Tested against 4.7.25 and the as-yet-unreleased 4.7.31. – universalhandle Jan 5 '18 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.