Reputation: 3192
I have tried several methods for this after searching online, including various SO answers.
Current I am trying this:
Form field code:
[dynamichidden form-session-id "form_session_id" id:fsid]
Code in Additional Settings:
on_sent_ok: 'location.replace("http://www.example.com/page-2/?fsid=" + jQuery("input[form-session-id=form_session_id]").val());'
After submitting my form I am redirected to:
http://www.example.com/page-2/?fsid=undefined
Can't get that fsid value in there! I admittedly don't know how to use this portion of the code:
input[form-session-id=form_session_id]
So that could be the issue...
I have also tried using this code in the Additional Settings field, as seen at https://wordpress.stackexchange.com/questions/19966/get-values-from-contact-form-7-wp-plugin:
function my_redirect() {
var fsid = document.getElementById('fsid').value;
var url = 'http://www.example.com/page-2/?fsid=' + fsid;
window.location = url;
}
on_sent_ok: 'my_redirect();'
In this case no redirect at all happens.
Upvotes: 1
Views: 3163
Reputation: 1
I've been looking all over for a similar solution and this worked! Using Contact Form 7, I'm selling tickets on PayPal and I have a quantity field the called 'ticketnumber'.
In Additional Settings I have this:
on_sent_ok: 'location.replace("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XXXXXXXXXL&quantity=" + jQuery("input[name=ticketnumber]").val());'
Works like a charm!
Upvotes: 0
Reputation: 6662
Does your page actually have this hidden field? On my page it wasn't rendered untill i remove id:fsid
part from the shortcode: [dynamichidden form-session-id "form_session_id"]
In on-sent-ok change input[form-session-id=form_session_id]
to input[name=form-session-id]
:
on_sent_ok: 'location.replace("http://www.example.com/page-2/?fsid=" + jQuery("input[name=form-session-id]").val());'
Upvotes: 1