The gform_agilecrm_tags filter allows you to dynamically modify the tags assigned to a contact in Agile CRM.
Usage
To apply this filter to all feeds:
add_filter('gform_agilecrm_tags', 'your_function_name', 10, 4);
To target feeds for a specific form, append the form ID to the hook name (format: gform_agilecrm_tags_FORMID):
add_filter('gform_agilecrm_tags_4', 'your_function_name', 10, 4);
Parameters
- $tags (array) – An array of tags to be assigned to the contact.
- $feed (Feed Object) – The feed currently being processed.
- $entry (Entry Object) – The entry currently being processed.
- $form (Form Object) – The form currently being processed.
More information
See Gravity Forms Docs: gform_agilecrm_tags
Examples
Always add tags
This example demonstrates how to add a new tag.
add_filter('gform_agilecrm_tags', 'add_new_tag', 10, 4); function add_new_tag($tags, $feed, $entry, $form) { $tags[] = 'some tag'; return $tags; }
Add tag depending on field value
This example demonstrates how to add a tag based on the value of an entry field.
add_filter('gform_agilecrm_tags', 'add_new_tag', 10, 4); function add_new_tag($tags, $feed, $entry, $form) { $product = rgar($entry, '15'); if ($product != 'gravityforms') { $tags[] = 'some tag'; } return $tags; }
Place this code in the functions.php
file of your active theme.
Remove tag if it exists
This example demonstrates how to remove a specific tag if it exists.
add_filter('gform_agilecrm_tags', 'remove_specific_tag', 10, 4); function remove_specific_tag($tags, $feed, $entry, $form) { $tag_to_remove = 'some tag'; $key = array_search($tag_to_remove, $tags); if (false !== $key) { unset($tags[$key]); } return $tags; }
Add multiple tags based on user input
This example demonstrates how to add multiple tags based on user input from a checkbox field.
add_filter('gform_agilecrm_tags', 'add_multiple_tags', 10, 4); function add_multiple_tags($tags, $feed, $entry, $form) { $checkbox_field = rgar($entry, '20'); $new_tags = explode(', ', $checkbox_field); $tags = array_merge($tags, $new_tags); return $tags; }
Modify tags based on conditional logic
This example demonstrates how to modify tags based on conditional logic.
add_filter('gform_agilecrm_tags', 'modify_tags_conditionally', 10, 4); function modify_tags_conditionally($tags, $feed, $entry, $form) { $field_value = rgar($entry, '10'); if ($field_value == 'option1') { $tags[] = 'tag1'; } elseif ($field_value == 'option2') { $tags[] = 'tag2'; } return $tags; }