Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filters out any empty merge_vars sent to MailChimp
<?php //Please do not include the opening PHP tag if you already have one
function tw_eea_mailchimp_filter_empty_merge_vars( $subscribe_args, $registration, $EVT_ID ) {
//Filter null values from merge_vars.
$subscribe_args['merge_fields'] = array_filter($subscribe_args['merge_vars'], function($merge_var) { return !is_null($merge_var); });
return $subscribe_args;
}
add_filter('FHEE__EE_MCI_Controller__mci_submit_to_mailchimp__subscribe_args', 'tw_eea_mailchimp_filter_empty_merge_vars', 999, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment