Last active
November 18, 2020 14:04
-
-
Save Pebblo/a53a6f50782b2eb0312f2efae7a8401c to your computer and use it in GitHub Desktop.
Filters out any empty merge_vars sent to MailChimp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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