Tim Tim - 6 months ago 46
Javascript Question

Form submit redirect not working using Contact Form 7 WordPress plugin

I'm using the Contact Form 7 plugin on my Wordpress site and I found a method to redirect the form to another URL from the documentation on this page.

I tried adding the following code to the additional settings field on my form:

on_sent_ok: "location = 'http://example.com/';"


I tested this on my website at the top of the page via the 'Request a quote' button and submitted. Unfortunately no redirect is forced.

Why is this feature not working? I'm using the form within the lightbox (this could be the reason), but I need to redirect to the homepage when you submit the form as it is a 'one-page' website.

Please feel free to test for yourselves, I only receive the test emails anyway at the moment.

Thanks

Answer

Well, I have a very simple solution:

Just add this to the first of the Messages fields in the Contact form, the one titled: "# Sender's message was sent successfully":

Your message was sent successfully.

<script>window.location.href = 'http://www.example.com';</script>
Comments