Description
The gform_activecampaign_contact_pre_sync filter can be used to override the contact properties before the contact_sync request is sent to the API.
Usage
The filter which would run for all ActiveCampaign feeds can be used like so:
add_filter( 'gform_activecampaign_contact_pre_sync', 'your_function_name', 10, 4 );
You can limit the scope of the filter to a single form by appending the form id on the end of the hook name like so:
add_filter( 'gform_activecampaign_contact_pre_sync_5', 'your_function_name', 10, 4 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact | array | The contact properties. See the ActiveCampaign API documentation for the full list of accepted properties. |
$entry | Entry Object | The entry currently being processed. |
$form | Form Object | The form object the current entry was created from. |
$feed | Feed Object | The feed which is currently being processed. |
Examples
Add the ip4 property to the array.
This example shows how you can add the ip4 property to the array.
add_filter( 'gform_activecampaign_contact_pre_sync', function( $contact, $entry, $form, $feed ) {
$contact['ip4'] = rgar( $entry, 'ip' );
return $contact;
}, 10, 4 );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This filter was added in ActiveCampaign 1.3.5.
Source Code
This filter is located in GFActiveCampaign::process_feed() in class-gf-activecampaign.php.