The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[Plugin: Contact Form 7] Issues with 'Redirecting to Another URL After Submission' (25 posts)

  1. circlecube
    Posted 6 years ago #

    So what is the correct syntax to forward a submitted form to a thank you page? I've found half a dozen different ways and none of them seem to work both in IE and FF. Actually only one would work in FF and none in IE that I've been able to tell. But now that I'm trying them again none of them work in FF either. I think I'm going crazy.

    The most trustworthy site for reference I would guess would be: http://contactform7.com/2010/03/27/redirecting-to-another-url-after-submissions/ and this it states to use:
    on_sent_ok: "location = 'http://example.com/';"

    looking through the forums after this solution didn't work I found:
    on_sent_ok: "location.href('http://example.com');"
    on_sent_ok: "location.href = 'http://example.com';"
    on_sent_ok: "window.location='http://example.com';"
    on_sent_ok: "location.replace('http://example.com');"

    The emails still get sent but the redirect does not. But when I put these on_sent_ok lines into the additional settings, the emails are sent but the feedback success message doesn't show up anymore. Validation error messages do still show up though.

    I'm using the latest version of the plugin (2.2.1) I have taken care to make sure the theme and the page include the wp_footer and have viewed the source on the page containing the form and see the /wp-content/plugins/contact-form-7/scripts.js?ver=2.2.1 file. I love this plugin, but have spent the better part of a full day trying to get this to work. Thought it was fixed once but then I checked the internet exploder and no dice. Any clarification or insights would be greatly appreciated. Thanks!


  2. jaymus
    Posted 6 years ago #

    My problem is similar. I had a form with a redirect that was working just fine. However, I upgraded to WordPress 3.0 and upgraded the Contact 7 plugin to 2.2.1 and now the redirect doesn't work. I get a spinning arrow that just sits there.

  3. achensee
    Posted 6 years ago #

    It seems that this is a major bug; we also used the on_sent_ok-Feature and it worked well before upgrading to WP 3.0. When submitting a form, the spinning arrow loads endless, no success-message appears, but the data was sent. When I removed all on_sent_ok commands the form was submitted and cleared, the success-message appears an everything seems to be okay. but this is no solution to me...

  4. Takayuki Miyoshi
    Posted 6 years ago #

    For WP 3.0 users, try the development version, please. It should have fixed the bug.


    Sorry for this inconvenience.

  5. rodwreck
    Posted 6 years ago #

    Thanks takayukister it works in WordPress 3.0 now!

  6. maorb
    Posted 6 years ago #

    I have the same problem too, that the redirection won't work.
    I use WP2.9.2 with latest version of contact form 7.

    I tried all the 4 different syntaxes of the redirection, but nothing works.
    It does send the mail with the form, but no redirection, just the ajax loader animated gif keeps showing.

    I also ofcourse, using the <?php wp_footer();?> in the theme.

    Should I also upgrade to the development version, as I use WP2.9.2 and not 3.0


  7. maorb
    Posted 6 years ago #

    Some more info about the problem:

    The page with the currently temp form is :

    When sending the form, firebuging it I see in the POST :

    _wpcf7 2
    _wpcf7_is_ajax_call 1
    _wpcf7_unit_tag wpcf7-f2-p1642-o1
    _wpcf7_version 2.2.1
    cellphone 050-333333
    email-117 a@a.com
    firstanme sss
    lastname 111
    phone 03-33333

    The server response is :

    { "mailSent": 1, "into": "#wpcf7-f2-p1642-o1", "captcha": null, "message": "Message sent successfully. Thankx", "onSentOk": ["location = \'http://gilagideon.co.il/?page_id=1445/\';"] }

  8. rbeazley
    Posted 6 years ago #

    I'd like to think I'm just having a blonde day - but after deleting the old version and uploading the redeveloped version, I still can't get the form to show?


    It IS working on this site for me with 3.0?? http://copperwest.ca/contact/

    Thanks in advance for your insight.

  9. JC001
    Posted 6 years ago #

    Circlecube - looks like you looked into this thouroughly!

    Did you solve it?

    I'm in the same boat (WP 3.0 - need to redirect forms to aa url on send_ok - but two different urls for two different forms).

    I upddated Contact Form 7 plugin to the development version posted by takayukister and it fixed the continually spinning ajax button.

    But I still can't get a page to redirect :-(

    However my html is not valid and my custom theme doesnt include wp_footer function it seems so i'll try those next as per the advice on contactform7.com

  10. maorb
    Posted 6 years ago #

    I use still 2.9.2 but I solved my issue.
    After spending lots of hours with this issue, I discovered that the call to Google's jQuery 1.4.2 was the source of the problem.
    When removing the call to jQuery, the on_sent_ok started to do the redirection as needed.
    So for the meantime, I added an if statement on my header.php, to exclude the jQuery call if this is the form page, which actually don't really need the jQuery library in it for me.
    Hope my hours of investigation will help someone here with this issue.

  11. rwilliams1961
    Posted 6 years ago #


    where do you and how do you remove the jquery call?


  12. yankeyhotel
    Posted 6 years ago #

    worked for me tooo!
    yeah. thank you.

  13. maorb
    Posted 6 years ago #


    I put this if statement in my header.php, inside the <head> section
    I removed for the form page both jQuery and two other js scripts that weren't needed.
    In my example, the form page id was 1612, just replace the number with your page's number:

    <?php if (!is_page('1612')) :?>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.cycle.all.min.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/script.js"></script>
    <?php endif;?>

    Hope it helps for the moment, and hope also that it will be fixed in the CF7 next version, if the plugin's creator visits this page :)

  14. cserron
    Posted 6 years ago #

    Greetings everyone!, I updated to the development version and it works in wp3 for me, but what I'm trying to do is this:

    I've contactform7 working together with a payment gateway plugin, and once the contact form (that is used as a checkout form) sends the e-mail, I want to redirect my information to another page. The problem is that the redirection cleans all my POST variables and I need to keep them on $_POST...ideas? :-p

    Thanks in advance.

  15. deewilcox
    Posted 6 years ago #

    I'm having the same issue. My forms send, and the data sends successfully, but I get the spinning arrow and no redirect. I am running WP 3.0 and uploaded the developer version of the plugin. I've checked for the AJAX functions in wp_header and wp_footer, and they are both there. I've also tried deactivating all other plugins. I've also tried adding the code from @maorb above to my header.php file, but it doesn't seem to have made a difference.

    I appreciate any ideas anyone might have!

  16. maorba
    Posted 6 years ago #


    When trying my code snippet, have you change the number of the
    to your specified page number that holds the form?

  17. mattfelten
    Posted 6 years ago #

    I just reset a site to use jQuery 1.3.2 and redirecting works fine. It wouldn't work with WP 3.0 and the newer jQuery 1.4.2 that it ships with.

    Hope this helps.

  18. deewilcox
    Posted 6 years ago #

    @maorba I did change the page ID. Here is what my header.php file looks like:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <title><?php bf_title(); ?></title>
    <?php bf_metaTags(); ?>
    <?php bf_head(); ?>
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php 
    if ($bf_feed_url) echo $bf_feed_url; else bloginfo('rss2_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>
    <?php if (!is_page('413')) :?>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.cycle.all.min.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/script.js"></script>
    <?php endif;?>
    <?php bf_top(); ?>
    <!-- begin #container -->
    <div id="container" class="clearfix">
    <?php bf_top_container(); ?>
    <!-- begin #header -->
    <div id="header" class="clearfix">
    <?php bf_header(); ?>
    <!-- end #header -->
    <?php bf_belowheader(); ?>
  19. deewilcox
    Posted 6 years ago #

    @mattfelten How did you downgrade your jquery? I've been trying to figure that out, as I've read in a few other places that it's a jquery/WP 3.0 compatibility issue. For now, I've just disabled jquery altogether in contact-form-7/wp-contact-form-7.php:

    if ( ! defined( 'WPCF7_LOAD_JS' ) )
    	define( 'WPCF7_LOAD_JS', false );

    I've also changed my success message to include a link to the redirect page where users can complete their registration purchase. I admit it's a terrible workaround, but it's all I've found that will work.

  20. carlitosWP
    Posted 6 years ago #

    I was wondering if there was a way to make the page a _blank page. In other words to open up a new page instead of redirecting.


  21. raasdesign
    Posted 6 years ago #

    Any new word on this? I can't believe it hasn't been addressed with more emphasis!

  22. shivark
    Posted 6 years ago #


    I am having the same issue! cant redirect to thank you page.
    tried everything but doesnt seem to be working.
    I have wordpres 3.0 contact form Version 2.3
    any solutions?

    Is there any way to add onClick function to the submit button?
    onClick="href....." somethink like that?

    what does script.js file do exactly, I am confused! when I disable this file (script.js) the form still works!
    and in the edit section of the plugins it says:
    "Editing contact-form-7/scripts.js (inactive)" why is that?


  23. alicewinthrop
    Posted 6 years ago #

    I had a strange issue with slashes being inserted into my form code as if it was trying to escape quotes for php but here it was in the html. I removed them all (and uploaded the dev version of cf7) and all working now. hope that helps someone.

  24. carlitosWP
    Posted 6 years ago #

    I answered my own question:

    on_sent_ok: window.open('http://dude.org', '_blank');

  25. Fee
    Posted 5 years ago #

    Does anyone know how to get the thankyou url? I dont want a separate page...just to track it but I dont understand anything ive read so far..

Topic Closed

This topic has been closed to new replies.

About this Topic