bookmark_bordergform_mailchimp_override_empty_fields

Description

This filter can be used to prevent empty form fields erasing values already stored in the mapped MailChimp MMERGE fields when updating an existing subscriber.

Usage

The filter which would run for all MailChimp feeds can be used like so:

add_filter( 'gform_mailchimp_override_empty_fields', 'your_function_name', 10, 4 );

To target a specific form append the form id to the hook name. (format: gform_mailchimp_override_empty_fields_FORMID)

add_filter( 'gform_mailchimp_override_empty_fields_10', 'your_function_name', 10, 4 );

Parameters

  • $override boolean

    The default is true.

  • $form

    The Form which is currently being processed.

  • $entry Entry Object

    The Entry which is currently being processed.

  • $feed Feed Object

    The Feed which is currently being processed.

Examples

1. Override all feeds

The following example shows how you can apply the filter to all MailChimp feeds.

add_filter( 'gform_mailchimp_override_empty_fields', '__return_false' );

2. Override specific feed

The following example shows how you can target a specific MailChimp feed.

add_filter( 'gform_mailchimp_override_empty_fields', function ( $override, $form, $entry, $feed ) {
    $feed_name = rgars( $feed, 'meta/feedName' );

    return $feed_name == 'Your feed name' ? false : $override;
}, 10, 4 );

Placement

Your code snippet should be placed in the functions.php file of your active theme.

Source Code

apply_filters( "gform_mailchimp_override_empty_fields_{$form['id']}", apply_filters( 'gform_mailchimp_override_empty_fields', true, $form, $entry, $feed ), $form, $entry, $feed )

This filter is located in GFMailChimp::process_feed() in class-gf-mailchimp.php