Title: [Plugin: Contact Form 7] Conditional redirect
Last modified: August 20, 2016

---

# [Plugin: Contact Form 7] Conditional redirect

 *  Resolved [MarkeyMark](https://wordpress.org/support/users/markeymark/)
 * (@markeymark)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-redirect-2/)
 * I’m using the on_sent_ok action in ‘Additional Settings’ to redirect to a payment
   page.
 * I would like to use a conditional redirect that directs the user different pages
   depending on whether a checkbox/radio button has been selected.
 * I’ve looked at the post by ckpicker who appears to be asking a similar question,
   however the code that has been used in his post displays an alert on the screen
   rather than redirecting to alternative pages.
 * I’d really appreciate some assistance with this.
 * Thanks in advance.
 * [http://wordpress.org/extend/plugins/contact-form-7/](http://wordpress.org/extend/plugins/contact-form-7/)
 * _[ Please do not bump, that’s [not permitted here](http://codex.wordpress.org/Forum_Welcome#No_Bumping).]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [MarkeyMark](https://wordpress.org/support/users/markeymark/)
 * (@markeymark)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-redirect-2/#post-3049283)
 * OK, I’ve done a little digging & I’ve come up with this code:
 * on_sent_ok: “if (jQuery(“#payment-type”).value() == “Invoice”) {location.replace(‘
   [http://www.mysite.com/invoice/&#8217](http://www.mysite.com/invoice/&#8217););}”
 * The email submission works, but unfortunately the redirect doesn’t work at all
   now.
 * Is it possible do to a conditional redirect with CF7 or do I need to look for
   an alternative method?
 * Thanks
 *  Thread Starter [MarkeyMark](https://wordpress.org/support/users/markeymark/)
 * (@markeymark)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-redirect-2/#post-3049372)
 * The code you need to add into the “Additional Settings” is as follows:
 * on_sent_ok: ” if (document.getElementById(‘paymenttype’).value==’Invoice’) {location.
   replace(‘[http://www.google.co.uk&#8217](http://www.google.co.uk&#8217);)} else{
   location.replace(‘[http://uk.yahoo.com/&#8217](http://uk.yahoo.com/&#8217);) }“
 * ‘paymenttype’ is the ID set on a drop-down menu & ‘Invoice’ is one of the selectable
   values.
 * Hope this helps somebody!!
 *  [jr2009](https://wordpress.org/support/users/jr2009/)
 * (@jr2009)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-redirect-2/#post-3049462)
 * Hey MarkeyMark!
 * Thanks for the code. I’m still having a problem with the conditional redirect;
   both options linked to the 2nd URL.
    Radio Button choices: Paypal, Bank Transfer
 * I put this code in the additional settings, but it always leads to Google page
   instead of Paypal.
    on_sent_ok: ” if (document.getElementById(‘paymentmode’).
   value==’Paypal’) {location.replace(‘[http://www.paypal.com&#8217](http://www.paypal.com&#8217);)}
   else { location.replace(‘[http://www.google.com&#8217](http://www.google.com&#8217);)}“
 * Any fix? 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Contact Form 7] Conditional redirect’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [jr2009](https://wordpress.org/support/users/jr2009/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-redirect-2/#post-3049462)
 * Status: resolved