Description
This filter can be used to modify how the add-on handles blank custom fields. The default behaviour is to remove custom fields which don’t have a value from the CustomFields array so they aren’t sent to Campaign Monitor.
Usage
The filter which would run for all Campaign Monitor feeds can be used like so:
add_filter( 'gform_campaignmonitor_override_blank_custom_fields', 'your_function_name', 10, 4 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$override | boolean | The default is false. |
$entry | Entry Object | The Entry which is currently being processed. |
$form | Form Object | The Form which is currently being processed. |
$feed | Feed Object | The Feed which is currently being processed. |
Examples
Override all feeds.
The following example shows how you can apply the filter to all Campaign Monitor feeds.
add_filter( 'gform_campaignmonitor_override_blank_custom_fields', '__return_true' );
Override a specific feed.
The following example shows how you can target a specific Campaign Monitor feed.
add_filter( 'gform_campaignmonitor_override_blank_custom_fields', function ( $override, $entry, $form, $feed ) {
$feed_name = rgars( $feed, 'meta/feedName' );
return $feed_name == 'Your feed name' ? true : false;
}, 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?
Source Code
This filter is located in GFCampaignMonitor::export_feed() in class-gf-campaignmonitor.php.