The gform_activecampaign_tags filter allows you to modify the tags that will be added to a contact in ActiveCampaign.
Usage
To apply the filter to all forms:
add_filter('gform_activecampaign_tags', 'your_function_name', 10, 4);
To apply the filter to a specific form:
add_filter('gform_activecampaign_tags_4', 'your_function_name', 10, 4);
Parameters
- $tags (array) – The current tags.
- $feed (Feed Object) – The current feed object.
- $entry (Entry Object) – The current entry object.
- $form (Form Object) – The current form object.
More information
See Gravity Forms Docs: gform_activecampaign_tags
Examples
Add a new tag
Add a new tag to the existing tags list.
add_filter('gform_activecampaign_tags', function($tags, $feed, $entry, $form) {
$tags[] = 'some tag';
return $tags;
}, 10, 4);
Remove a specific tag
Remove a specific tag if it exists in the list.
add_filter('gform_activecampaign_tags', function($tags, $feed, $entry, $form) {
if (($key = array_search('tag_to_remove', $tags)) !== false) {
unset($tags[$key]);
}
return $tags;
}, 10, 4);
Add tag based on a field value
Add a tag based on a field value in the form.
add_filter('gform_activecampaign_tags', function($tags, $feed, $entry, $form) {
if ($entry['field_id'] == 'specific_value') {
$tags[] = 'new_tag';
}
return $tags;
}, 10, 4);
Add tags based on the form ID
Add different tags depending on the form ID.
add_filter('gform_activecampaign_tags', function($tags, $feed, $entry, $form) {
if ($form['id'] == 1) {
$tags[] = 'form1_tag';
} elseif ($form['id'] == 2) {
$tags[] = 'form2_tag';
}
return $tags;
}, 10, 4);
Combine tags from multiple fields
Add tags based on the values of multiple fields in the form.
add_filter('gform_activecampaign_tags', function($tags, $feed, $entry, $form) {
if ($entry['field1_id'] == 'value1' && $entry['field2_id'] == 'value2') {
$tags[] = 'combined_tag';
}
return $tags;
}, 10, 4);