This documentation relates to CiviCRM version 3.2. It's not maintained anymore.
Current version of documentation.

Tagging APIs

Skip to end of metadata
Go to start of metadata

This page refers to outdated version of CiviCRM. Check current version of documentation.


Documentation Search


CiviCRM 3.2 Documentation

Support and Participation

Developer Resources


CiviCRM book!

Make sure to check out Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

Tag APIs

civicrm_tag_create(&$tag)

File: api/v2/Tag.php

Availability: v2.0
Returns array of Contact Id related to Tag ID. If array is empty, then all Contact ID returned in array.
Add a tag. Tags are used to classify CRM entities (including Contacts, Groups and Actions). Use crm_entity_tag_add to assign an entity to a tag.

Parameters:

  • 'params' (array) Associative array of "property_name"=>"value" pairs to insert the Tag. Refer to the CRM Data Model for available properties.
  • for updating Tag record pass tag id in array like $params['tag']

Returns:

  • A new tag array.
    Create Tag
    Result

civicrm_tag_delete(&$tag)

File: api/v2/Tag.php

Availability: v2.0

Deletes an existing Tag.

Parameters:

  • 'tag' Valid tag array.

Returns:

  • Null - if successfull, 'object of CRM_Core_Error' - otherwise.
    Deleting a Tag

    Deleting a Tag will result in deletion of all Tag_entity assignments for that tag. For example, any Individuals assigned to a deleted tag will no longer be tagged for that tag.


    Delete Tag
    Result

civicrm_tag_get(&$tag)


File: api/v2/Tag.php

Availability: v2.0
Returns array of Details related to Tag ID / Name.

Parameters:

  • 'params' (array) Associative array of "property_name"=>"value" pairs to get details of the Tag. Either of Id / Name is required to fetch the record.

Returns:

  • A array of details.
    Get Tag
    Result

Tag Entity APIs

civicrm_entity_tag_get( &$params )

File: api/v2/EntityTag.php

Availability: v2.0
Returns array of Tag Id related to Contact ID.

Get Tag ID
Result

civicrm_tag_entities_get( &$params )

File: api/v2/EntityTag.php

Availability: v2.0
Returns array of Contact Id related to Tag ID. If array is empty, then all Contact ID returned in array.

Returns:

  • Array of Contact ID
  • Null (if there are no applicable related contacts).
    Get Contact ID
    Result

civicrm_entity_tag_common( &$params, $op = 'add' )

File: api/v2/EntityTag.php

Availability: v2.0

civicrm_entity_tag_add(&$tags_and_entities)

File: api/v2/EntityTag.php

Availability: v2.0

Assigns an entity (e.g. Individual, Organization, Group, Contact_action) to a Tag (i.e. 'tags' that entity).

Parameters:
An array including at least one Tag array and at least one Entity array.

Returns:

  • An array with statistics.
Example for civicrm_entity_tag_add

civicrm_entity_tag_remove(&$tags_and_entities)

File: api/v2/EntityTag.php

Availability: v2.0

Deletes an existing entity tag assignment.

Parameters:

  • Array of Contact and Tag arrays.
    ( If want to Remove more than one tag of Contact: use tag_id_1, tag_id_2 where 1, 2 used for differentiate the tag key in array, for single tag remove use tag_id in array )

Returns:

  • Array of statistics if successful, 'object of CRM_Core_Error' - otherwise.
    Remove Entity Tag
    Result
Labels
  • None

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.