Telephone: 0844 967 0565 Email: info@pushon.co.uk

Contact Form 7: Redirect to a Thank You (Success) Page in WordPress 3

Just a quick blog post today – but it’s probably very useful for people having issues with contact form 7 no longer redirecting properly to a ‘thank you’ page. The previous method of redirecting to a thank you page in the contact form 7 WordPress plugin was to add a line of code to the ‘Additional Settings’ section in the plugin settings – but this method no longer appears to work while using WordPress 3. The solution, however, is relatively simple:

Firstly, make sure you have gone through the process of upgrading your website/blog to WordPress 3 (including all plugins).

Now, download the BETA version of contact form 7 that is currently in development, found here:
http://downloads.wordpress.org/plugin/contact-form-7.zip
(note: use beta versions of software at your own risk)

Backup the current contact form 7 plugin files in the plugins folder (located at /wp-content/plugins), and install the BETA version of the plugin.

Finally, in the contact form 7 settings, replace any previous code you had in the ‘Additional Settings’ field with the following:

on_sent_ok: "location = 'http://www.example.com/thank-you/';"

Obviously replace the ‘example.com’ website URL with a link to your desired thank you (success) page.

That should do it – feel free to leave a comment below if you are having trouble getting it to work.

To find out how PushON research & analysis services can give your company a competitive online edge, simply call 0844 967 0565 or contact us via our form.

  • Pingback: Contact Form 7 – Thank You Page | Web Toastie

  • http://www.thefloatingfrog.co.uk Frog

    I love you, this worked! Now to fathom out how to add JS to just the thank you page :S

  • http://www.kaydinsdale.co.uk kay dinsdale

    Thanks for this tip Keiron, I use contact form 7 on a couple of blogs but find it’s a bit clunky and slow in sending the message. I recently found the ‘fast and secure contact form’ (http://wordpress.org/extend/plugins/si-contact-form/) which I’m using on http://www.manchesterseo.org.uk. So far I’m impressed and prefer it to contact form 7. Take a look :)

  • Sam

    It’s not working for me and I have no idea what else to do. I feel like I’ve tried everything. Please help!

  • obi

    it doesnt work >_<

  • http://www.growthclick.com Tom

    Thanks so much – this is a great plugin and your fix has been a huge help!

  • http://www.briannourse.co.uk brian

    still does not work – any ideas, did all the above and still hangs. stupid plugin.

  • http://www.pushon.co.uk Kieron Hughes

    Hi Brian,

    If you are working on your website in a test environment (or are able to test changes) I would suggest disabling any other plugins you may have running, then see if Contact Form 7 will redirect. Sometimes conflicts can be caused with other plugins installed in WordPress.

    If there are no plugin conflicts then it could be a number of possible issues. What version of WordPress are you currently using? I haven’t tested the above fix on WordPress 3.0.1, but I’d imagine it should work (tested on a number of sites with 3.0 and had no problems as of yet).

    Also, did you download the plugin directly from the link I provided above? The one available as the main instance of Contact Form 7 is slightly different, so you have to use the file I linked to.

    Feel free to ask any more questions if you still can’t get it working.

    Cheers,

    Kieron

  • admintiger

    The BETA version of Contact Form 7 fixes the redirect problem with Firefox, but not with Internet Explorer.

  • http://erica.biz/ Erica Douglass

    Works for me in both IE/FF as well as Chrome. Thank you!

  • mazhar

    if you want to redirect to success page you urs than you have to edit scripts.js file add the line below 1 == data.mailSent

    like :

    if (1 == data.mailSent) {
    jQuery(data.into).find(‘form’).resetForm().clearForm();
    wpcf7ResponseOutput.addClass(‘wpcf7-mail-sent-ok’);
    location.href=”http://www.yourdomain.com/yourthankyoupage”;

  • mazhar

    you can find the script file in

    wp-content\plugins\contact-form-7

    if you still face the error 404 page problem than simply add the below code in footer.php file of theme

    wp_footer();

    Note wp_footer(); function should be in php tag like:

  • http://www.stephaniecockerl.com Stephanie Cockerl

    Thanks for the tip. It worked!

  • Fred

    Cant get that to work mazhar.

  • http://www.usabilityforce.com zeshan

    i have tried alll, but its not working for me plz help:(

  • http://www.groundedgroup.com/ JHouse

    F yeah, great piece of code there. Thanks. Works like a champ!

  • http://www.smallbizwebwhiz.com Hilary Brooks

    This works fantastic! For me, Contact Form 7 beta version was not required. I simply added the code to the settings area and viola! Thanks so much for providing this helpful tip!

  • http://www.urbinfos.com Aetys

    It’s working for me, thank you !

  • http://twitter.com/webiinet WEBii.net

    Thank you, Kieron. This was very helpful in a recent website upgrade for one of our customers. I have always found the default “green outline message” to lack the usability and sleekness that a website really needs.

  • Neil

    Hi Kieron. This was working for me a few months but not so anymore. Have any updates stopped it from working?

    Currently my url redirects to something like this: http://www.example.com/#wpcf7-f3-p934-o1 (the content stays the same – so there is no ‘success page’)
    when previously it use to redirect to http://www.example.com/thank-you/ just like you say in your post.

  • http://www.itabs.de/magento Magento Agentur

    nice code, great work!

  • http://twitter.com/Newnab Adam Burt

    Anyone still having trouble with this, you could try the PHP way – Add something like this to your functions.php file:

    function redir_after_form_sent($form) {
    if ($form->title == “Ask a question”) {
    header(‘Location: /thank-you’);
    die();
    }
    }
    add_action(‘wpcf7_mail_sent’, ‘redir_after_form_sent’);

  • http://www.templatespress.com/ Templatespress

    hi “Adam Burt” it not working for me

  • Dennis de Roo

    People who having trouble with this, be sure you’ve added wp_footer() just before the closing tag.

    • Dennis de Roo

      * closing body tag

  • Paddy Ryan

    Hi guys, I know this has been covered before, but I’ve tried the adding code to function.php and tried the redirect via the additional settings. Nothing seems to be working :( Like everyone else, I’m trying to redirect the form to a landing page post form submission!! Any help will be GREATLY appreciated!!