Support » Plugin: Contact Form 7 » Invisible Form and Submission

  • Resolved thaynejo

    (@thaynejo)


    I really like the way CF7 works. I need to create something with a similar function and would like to use CF7 to do so.

    Basically, I need to create an invisible form that submits automatically on page load. It then redirects to a thank you page on submission.

    I can trigger the form submission on page load, but it continues to submit the form without ever triggering the page redirection defined in “on_sent_ok”.

    I need to be able to identify when the form has been submitted, but haven’t found any clue in that direction.

    Any ideas as to what to look for?

    https://wordpress.org/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • Thread Starter thaynejo

    (@thaynejo)

    I found the solution for my issue.

    I found that the key is that when the form is submitted, the “sent” class is added to the <form> tag. As such I added a test to see if it exists and redirects to the thank you page if it does.

    Added code:

    <script type="text/javascript">
    jQuery(function($){
      if (!$("form.wpcf7-form").hasClass("sent")) {
        $("form.wpcf7-form").submit();
      } else {
        window.location="url";
      }
    });
    </script>
Viewing 1 replies (of 1 total)
  • The topic ‘Invisible Form and Submission’ is closed to new replies.