Title: Make checkbox required in Contact Form 7
Last modified: November 12, 2018

---

# Make checkbox required in Contact Form 7

 *  Resolved [chever](https://wordpress.org/support/users/chever/)
 * (@chever)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/)
 * Hello. Is there any way to make [mc4wp_checkbox] as s required field and if it
   is not checked it will be a typical contact form 7 error validation?
    I want 
   it because I want to use exactly form only for subscribing to mailchimp. I have
   tried [mc4wp_checkbox*] and it is not working – destroying shortcode.

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Contributor [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10871691)
 * Hello,
 * To make the CF7 checkbox as a required field, please add the following code to
   the “functions.php” file located inside your active theme folder.
 *     ```
       /**
        * 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'] );
       });
       ```
   
 * I hope that answers your query. Let us know if you have any further questions.
 *  Thread Starter [chever](https://wordpress.org/support/users/chever/)
 * (@chever)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10872228)
 * Great, it is working so. Thank you very much!
 *  Thread Starter [chever](https://wordpress.org/support/users/chever/)
 * (@chever)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10877330)
 * Update: with this code in functions.php I see that I have error with acceptance
   in simple CF7 forms that are not used for subscribing, but only for user’s feedbacks.
   So how to make this your code working only when in CF7 is [mc4wp_checkbox] shortcode?
 *  Plugin Contributor [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10877786)
 * Hello,
 * Can you please share a link to the 2 pages where a CF7 form is used with our 
   shortcode as well as a CF7 form without our checkbox/shortcode?
 *  Thread Starter [chever](https://wordpress.org/support/users/chever/)
 * (@chever)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10878574)
 * Hello,
 * [https://bit.ly/2DCVsMh](https://bit.ly/2DCVsMh) – this is where CF7 form in 
   the right columb is used for subscribing, so it is with your shortcode and it
   is working.
 * [https://bit.ly/2OIIBsX](https://bit.ly/2OIIBsX) – this is 404 page and there
   is simple CF7 form with simple cf7 acceptance checkbox but I understand that 
   it wants the [mc4wp_checkbox] shortcode to be checked… Because of code in function.
   php
    If I remove acceptance field here [https://bit.ly/2OIIBsX](https://bit.ly/2OIIBsX)
   I have the same error about accept something… Also tried with add this line to
   the Additional Settings section: acceptance_as_validation: on No result. Help
   me plesase)
 *  Thread Starter [chever](https://wordpress.org/support/users/chever/)
 * (@chever)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10882651)
 * Can you help? Please
 *  Plugin Contributor [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10890304)
 * Hello,
 * Please note that 2 links you shared are not accessible. A pop-up login box is
   displayed. Have you setup Htaccess based security?
 *  Thread Starter [chever](https://wordpress.org/support/users/chever/)
 * (@chever)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10890313)
 * Yes sorry, I forgot for this)
    Topic can be closed, because I have fixed it. 
   I have stopped using shorctode in cf7, i just using mailchimp form separatly 
   from cf7 forms.
 *  Plugin Contributor [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-10890316)
 * Hey,
 * Thanks for the update.
 *  [gearu](https://wordpress.org/support/users/gearu/)
 * (@gearu)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-11241035)
 * I’ve used the function you’ve provided as well – which works great. However, 
   how do I stop it applying to ALL contact form’s? I only want it to apply to my
   newsletter subscription, but not to my contact form?
 * I’m happy to hard code the ID into the function so it only applies to a specific
   form – I’m just not sure how to do this (or if there is a better way?)
    -  This reply was modified 7 years, 2 months ago by [gearu](https://wordpress.org/support/users/gearu/).
 *  [josephhh](https://wordpress.org/support/users/joseribeiro/)
 * (@joseribeiro)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-11820314)
 * Hello,
 * This is exactly my problem too. What is the fix for this issue?
 * Thank you

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Make checkbox required in Contact Form 7’ is closed to new replies.

 * ![](https://ps.w.org/mailchimp-for-wp/assets/icon-256x256.png?rev=1224577)
 * [MC4WP: Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp-for-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp-for-wp/reviews/)

 * 11 replies
 * 4 participants
 * Last reply from: [josephhh](https://wordpress.org/support/users/joseribeiro/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/make-checkbox-required-in-contact-form-7/#post-11820314)
 * Status: resolved