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
4 Answers
Reset to default 4Just 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