WordPress.org

Support

Support » Plugins and Hacks » Contact Form 7 » [Resolved] [Plugin: Contact Form 7] Conditional redirect

[Resolved] [Plugin: Contact Form 7] Conditional redirect

  • 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/

    [ Please do not bump, that’s not permitted here. ]

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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/’);}”

    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

    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’)} else { location.replace(‘http://uk.yahoo.com/’) } “

    ‘paymenttype’ is the ID set on a drop-down menu & ‘Invoice’ is one of the selectable values.

    Hope this helps somebody!!

    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’)} else { location.replace(‘http://www.google.com’) } “

    Any fix? 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: Contact Form 7] Conditional redirect’ is closed to new replies.
Skip to toolbar