WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Conditional redirect (4 posts)

  1. MarkeyMark
    Member
    Posted 2 years ago #

    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. ]

  2. MarkeyMark
    Member
    Posted 2 years ago #

    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

  3. MarkeyMark
    Member
    Posted 2 years ago #

    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!!

  4. jr2009
    Member
    Posted 2 years ago #

    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? :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic