WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Is Conditional Redirect Possible? (5 posts)

  1. EfremJ
    Member
    Posted 1 year ago #

    Hi,

    I've been using CF7 for years now and love its simplicity. One thing that I very much need my form to do, however, is to conditionally redirect a person to one page or the other--based on which radio button they choose in one of my forms.

    For example, if they choose the radio button "Option 1", they get redirected to a page for that option.

    If they choose the radio button "Option 2", they get taken to a different page, for that option.

    I was trying to follow the logic and approach in this post (http://wordpress.org/support/topic/plugin-contact-form-7-conditional-redirect?replies=15) but feel like the kid who got left behind in the classroom. I'm just not understanding how to do what I need my form to do.

    Any help would be greatly appreciated.

    Regards,

    -Efrem

    http://wordpress.org/extend/plugins/contact-form-7/

  2. e
    Member
    Posted 1 year ago #

    Hi EfremJ,

    Here's an article with exactly your example:

    WordPress Contact Form 7 Hook Unofficial Developer Documentation and Examples

    See Changing email recipient dynamically depending on code

  3. EfremJ
    Member
    Posted 1 year ago #

    Hi, e.

    Thanks for the link. I just spent the last 45 minutes trying to get my form to work but to no avail. ;-}~

  4. MarkeyMark
    Member
    Posted 1 year ago #

    Hi EfremJ,

    I was having a similar issue, but trying to to a conditional redirect using a drop-down menu. I eventually got this to work. The link below takes you to the post I added requesting support. I've posted the working code on there.

    http://wordpress.org/support/topic/plugin-contact-form-7-conditional-redirect-2?replies=3#post-3201230

    Hope it helps.

  5. EfremJ
    Member
    Posted 1 year ago #

    Hi, MarkeyMark.

    Thanks for the tips and post reference. I got the redirect to work--to a certain degree--but what I noticed is that CF7 clears the form values after submit so the value of the radio button I'm using doesn't even get recorded.

    What happens is that the page winds up on the "else" URL by default since it never sees the other choice. Does that make sense?

    This is what I have in my form element:
    [radio your-payment id:paymenttype default:1 "Pay-in-Full" "3-Payments*"]

    This is what's in my Additional Settings:
    on_sent_ok: " if (document.getElementById('paymenttype').value=='3-Payments') {location.replace('/3paycart')} else { location.replace('/pzcart') } "

    So when I select 3-Payments on my form and submit it, it always winds up on /pzcart instead of /3paycart because the values have already been cleared by CF7.

    Are you getting the same issues?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic