• Resolved Dimis99

    (@dimis99)


    Hello,

    Is it possible to make MC4WP consent checkbox required, ONLY for one form?

    I found and used the code in the support ticket bellow, but this code adds the requirement to all the Contact Forms, even if they don’t have inside them [mc4wp_checkbox] shortcode.

    Thank you in advance.
    Dimis

    https://wordpress.org/support/topic/required-checkbox-with-cf7/

    /**
     * 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'] );
    });
Viewing 1 replies (of 1 total)
  • Plugin Contributor Lap

    (@lapzor)

    You can check the $_POST for some other variable identifying the form.

    eg something like (untested) for the form with ID 1234.

    add_filter( 'wpcf7_acceptance', function( $yes ) {
    	if( ! $yes && $_POST['_wpcf7'] == "1234") { return false; }
    	return ! empty( $_POST['_mc4wp_subscribe_contact-form-7'] );
    });

    Custom code like this, especially relating to third party plugins like CF7 and even more so when it’s something easily done in our Premium addon is our of scope for our support so for further help with this I recommend hiring a PHP developer to write the code for you.

    Hope that helps. If you have any questions, please let me know!

Viewing 1 replies (of 1 total)
  • The topic ‘Required checkbox with CF7 only for one form’ is closed to new replies.