Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a Contact Form 7 form that needs to redirect to specific pages depending on how the user arrived at the form. I'm storing the URL they need to be redirected to using localStorage and I'm trying to figure out how to tell contact form 7 this stored URL to use for redirection when the user clicks "Submit".

i.e. the basic redirection method within CF7's "Additional Settings" is:

on_sent_ok: "location.replace('http://www.YOURSITE.com');"

and I'm trying to set the URL using javascript:

var newUrl = localStorage.getItem('storedurl');}

on_sent_ok: "location.replace( newUrl );"}

Doesn't have to call localStorage from within CF7, it could just call in a variable that's been set globally. But I can't get either to work.

Thanks!

share|improve this question

1 Answer 1

Turns out there were some variable problems with that code. I've changed it to this and its working now!

on_sent_ok: "location.replace( localStorage.getItem('storedurl') );"

Where storedurl is the key for the stored URL in local storage.

Not sure why the variables weren't working but that's a story for another day!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.