Redirecting to another url after contact form 7 submission

As we know, Contact Form 7 redirects to the same URL as the formโ€™s URL after form submissions in the default settings. However, sometimes, we might need to change this to redirect on another URL after submissions like ‘thank you page’ or need to do some other action on it.

The way is using ‘on_sent_ok’ JavaScript action hook. By using this hook, we can specify a JavaScript code that we wish to run after the form is successfully submitted. We can place it in the Additional Settings field at the bottom of the contact form management page. Simply insert the following line into it:

We need to replace the http://example.com/ to the URL you want to redirect to.

So just try it and resolve our problem of redirecting to another url after contact form 7 submission.

You Might Interested In

4 COMMENTS

  1. higa says:

    Very nice. One question if you can answer it. I would love that i get a message “Thank you for your email” but in the same contact form 7 window. So it collapse/hide and shows that message. Is that possible?

    Reply
    1. Amit Sonkhiya says:

      You can set thank you message in Contact Form 7 settings under your dashboard itself using <div id=”response”></div>. Check Contact Form 7 documentation for that.

      To collapse/expand you would need some custom JavaScript code to place.

      Reply
    1. Amit Sonkhiya says:

      You can update the code as following to open page in new window:

      on_sent_ok: “window.open(‘http://example.com’)”

      Reply

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.