• I have 2 identical forms on a page, due to drastic design change in desktop and mobile.

    Each time the form submits, I receive 2 emails. I believe its the hidden form causing this, as choosing another template without a duplicate form is fine.

    Is there anyway to disable a hidden form from being processed? Validation and submission wise?

    Thanks.

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 3 replies - 1 through 3 (of 3 total)
  • you can simply hook into wpcf7_posted_data this will show you the form data as it is posted, include a hidden field in your mobile form, or if you have an existing field which is different form the normal form use that instead

    add_filter( 'wpcf7_posted_data', 'filter_my_cf7_posted_data' );
    function filter_my_cf7_posted_data($posted_data){
      //check if this is a mobile device
      if(isset($posted_data['my-mobile-form-hidden-field']) && !wp_is_mobile()){ //this is the mobile form but the browser is not a mobile device
        $wpcf7 = WPCF7_ContactForm::get_current();
        $wpcf7->skip_mail = true; //skips the email being sent
      }
      return $posted_data;
    }
    Thread Starter resting

    (@resting)

    That’s interesting.
    I guess there’s no documentation on hooks and filters?
    Will have to dig in the source for such things ya?

    The best way is to look at other CF7 plugin extensions and see how they have developed it using CF7 functions and hooks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disable hidden form’ is closed to new replies.