• Resolved wastingdrip8447

    (@wastingdrip8447)


    I noticed that CF7 have implemented a new way of redirecting the contact form by using javascript. But right now our landing page has 2 forms: Form 1 has to be redirect to a specific page and Form 2 has to redirected to a thank you page (as requested by my client) and both forms are existing on the same page. I would like to ask what necessary steps should I take?

    Looking forward to your immediate reply. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    You can do it by specifying a narrower event target. See DOM Events. There is an example doing it with querySelector().

    I was able to get it to work, but how to redirect multiple contact forms to different thank you pages?

    @acufftg you probably figured this out, but here’s some instructions for anyone who lands on this from a search:

    For this example I want only the form on the page with ID 1 to go to a different redirect URL. You just need to have something unique to work, in my case it was the specific page. So I set a selector to look for that page ID. If that page ID isn’t null then I’m on that page and set the redirect to the second thank you page. If it’s null, then I’m not on that page and go to the normal redirect URL.

    <script>
    var wpcf7second = document.querySelector( '.page-id-1' );
    
    document.addEventListener( 'wpcf7submit', function( event ) {
    
    if(wpcf7second != null) {
    	location = 'https://www.lskfirm.com/thank-you-second/';
    }
    else {
    	location = 'https://www.lskfirm.com/thank-you/';
    }
    
    }, false );
    </script>

    What about if you needed 3? That would not work.
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘CF7 Redirect’ is closed to new replies.