If you are connecting an Advanced Form to MailChimp and need to restrict MailChimp sign ups based on a condition, you may do so using a custom submission handler to override the form's MailChimp configuration dynamically during submit.
In the below example, we check to see if the submission has a checked true/false field named 'add_to_mailchimp'. If it doesn't, the form's MailChimp configuration is set to FALSE which prevents the data from being sent to MailChimp.
// Use a true/false field as an opt-in for MailChimp. add_filter( 'af/form/submission', function ( $form, $fields, $args ) { // If we aren't handling the desired form, return early. if ( $form['key'] !== 'FORM_KEY_HERE' ) { return $form; } // If a particular true/false field isn't checked, disable the MailChimp integration for this submission. if ( ! af_get_field( 'add_to_mailchimp' ) ) { $form['mailchimp'] = false; } return $form; }, 5, 3 );
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article