Make MC4WP checkbox required for only 1 CF7 form
-
I have a CF7 Mailchimp signup form I’m using MC4WP with, and have a name, email and submit with a checkbox. If the box is checked, the user is subscribed. (double opt in is off per client request) But if it’s not checked, the user isn’t subscribed, but the message on submit is the same as if they had checked the button. (Thank you for subscribing…)
Someone posted the following code in order to make the checkbox required. But it also makes ALL CF7 forms require a MC4WP checkbox, so it basically breaks contact forms.
/** * By default, Contact Form 7 disables HTML5 validation so we can not use the default <code>required</code> attribute. * * This code uses CF7 logic to ensure that the subscribe checkbox is checked. */ add_filter( 'wpcf7_acceptance', function( $yes ) { if( ! $yes ) { return false; } return ! empty( $_POST['_mc4wp_subscribe_contact-form-7'] ); });
What I’d like to know is how do I modify this code to only work on a particular form, (the Mailchimp signup form) and leave the other forms alone?
This question was posted on the MC4WP support forum, and was directed here. I’ve searched and haven’t found this exact issue on this forum. Thanks in advance for any help you can provide.
- The topic ‘Make MC4WP checkbox required for only 1 CF7 form’ is closed to new replies.