• Resolved naroha

    (@naroha)


    Hey I tried to make the mw4wp_check required with the given code from previous thread:

    /**
     * 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'] );
    });

    But somehow when either I use [mc4wp_checkbox] or [acceptance mc4wp_checkbox] this doesn’t work. The [mc4wp_checkbox] isn’t required and the form still being pushed without Opt-In. The [acceptance mc4wp_checkbox] is required but doesn’t trigger the mc4wp_checkbox functionality. What exactly am I doing wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @naroha,

    In that case, you can use the HTML code directly. Instead of using the CF7 integration, on the “MC4WP > Integrations” menu you will find a “Custom” integration option. You can use that HTML code in your CF7 form.

    Thread Starter naroha

    (@naroha)

    Thanks for the quick response. I tried your mentioned solution and input:

    <p>
    	<label>
    		<input type="checkbox" name="mc4wp-subscribe" value="1" />
    		Subscribe to our newsletter.	</label>
    </p>

    But somehow the box still isn’t required. Or should the name be same as in the code? (“_mc4wp_subscribe_contact-form-7”)

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @naroha,

    Yes, please change the field name to match the code and then try again.

    Also, can you please share the link where this form is placed?

    Thread Starter naroha

    (@naroha)

    Hey sorry for the late response.
    I tried switching the name field and also the name in the code. They are exact same but somehow it doesn’t trigger at all. The form is here https://www.coconet.de/en/resources/

    Plugin Contributor Lap

    (@lapzor)

    
    <label>
    <input type="checkbox" name="mc4wp-subscribe" value="1" required />
    Subscribe to our newsletter.
    </label>

    To make i required you need to still add the required attribute to the field, as example above.

    Note that this will switch you from the WP7 integration to the Custom integration method. So set the list under Mailchimp for WP > Integrations > Custom.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘MC4WP Newsletter Checkbox’ is closed to new replies.