Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am doing a survey using the plugin "Contact Form 7". I want to insert an acceptance box. ONLY if people check this box and click "submit", they should be redirected to another page, where I am going to ask for their e-Mail-addresses.

If they don't check "acceptance" there should be no redirecting.

How can I do this?

I ready inserted on_sent_ok: "location = "" - BUT: This ignores if the acceptance box is check or not.

share|improve this question

2 Answers

Maybee this helps:

http://drzaus.com/snippet/wordpress-is-contact-form-7-missing-on_submit-callback

here on submit event you can check if acceptance imput is checked and then redirect them with

window.location = 'http://example.com/your-another-page';
share|improve this answer

I found an answer myself:

Redirecting without a condition When you use the Wordpress plugin “Contact Form 7” you can redirect the user to another page after submitting the answers by the follwing code:

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

The line of code you have to copy into the “settings” box at the end of a specific form you created.

Redirecting on a condition If you want to make the redirecting depending on a specific answer, you can use the following code:

on_sent_ok: " if (document.getElementById('car').value=='yes') {location.replace('http://www.redirectedpage1.com')} else { location.replace('http://www.redirectedpage2.com/') } "

The code in bold letters has to be changed by your settings.

For example: The question with the id “car” has two possible answers: “Yes” or “No”. If a person selects “Yes” he or she should be redirected to “http://www.redirectedpage1.com”. If “No” is selected, the user should be redirected to “http://www.redirectedpage2.com/”.

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.