最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Wordpress Send Form Data on Redirection in Contact Form 7 - Stack Overflow

programmeradmin1浏览0评论

I'm using the popular wordpress plugin called Contact Form 7. Its easy to redirect the form after submitting to any page by adding this code on_sent_ok: "location = '/';", but it does not carry the form values entered over, because its an AJAX submit.

The sites directions says `The simplest way is using on_sent_ok JavaScript action hook. By using this hook, you can specify a JavaScript code that you wish to run after the form is successfully submitted. You will find the Additional Settings field at the bottom of the contact form management page."

Would anyone be able to help or explain how I could carry the form values over on the redirect?

This is the redirection page I got from Contact Form 7

/

I'm using the popular wordpress plugin called Contact Form 7. Its easy to redirect the form after submitting to any page by adding this code on_sent_ok: "location = 'http://example./';", but it does not carry the form values entered over, because its an AJAX submit.

The sites directions says `The simplest way is using on_sent_ok JavaScript action hook. By using this hook, you can specify a JavaScript code that you wish to run after the form is successfully submitted. You will find the Additional Settings field at the bottom of the contact form management page."

Would anyone be able to help or explain how I could carry the form values over on the redirect?

This is the redirection page I got from Contact Form 7

http://contactform7./redirecting-to-another-url-after-submissions/

Share Improve this question asked Aug 15, 2014 at 2:04 Michael FalcigliaMichael Falciglia 1,0464 gold badges20 silver badges36 bronze badges 1
  • I believe what you have is just for redirecting after a successful form submission. I believe you need to attach your form data to an object on the hook. I thought this site helped contactform7./… – Four_lo Commented Aug 15, 2014 at 2:34
Add a ment  | 

4 Answers 4

Reset to default 4

Just use this hook:

on_sent_ok: "location = 'https://gettinmobile./my-account/checkout/?level=1&' + $('form.wpcf7-form').serialize();"

This will append all the form data as parameters in the query string.

Cheers, from La Paz, Bolivia

The on_sent_ok is being phased out.

Note: The method using on_sent_ok hook is no longer remended. This function is scheduled to be abolished by the end of 2017.

https://contactform7./redirecting-to-another-url-after-submissions

This is the new way to redirect contact form 7 on submission. Place in functions.php

add_action( 'wp_footer', 'redirect_cf7' );
   function redirect_cf7() {
   ?>
      <script type="text/javascript">
         document.addEventListener( 'wpcf7mailsent', function( event ) {
         location = 'https://www.example./thank-you/';}, false );
      </script>
   <?php
}

NOTE: This will redirect all contact form 7 submission to that thank you page

To add a 'redirection' function in the Contact Forms 7 you can just use the free plug-in: Redirection for Contact Form 7 by Qube One

发布评论

评论列表(0)

  1. 暂无评论