gform_campaignmonitor_override_blank_custom_fields

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

ParameterTypeDescription
$overridebooleanThe default is false.
$entryEntry ObjectThe Entry which is currently being processed.
$formForm ObjectThe Form which is currently being processed.
$feedFeed ObjectThe 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.