The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Contact Form 7
[resolved] Redirect URL based on inputs (7 posts)

  1. danicasati
    Posted 2 years ago #

    I'd like to collect any inputs based on text fields and use these to generate a custom URL.
    After submit, I'd like to redirect to this customized URL.

    Is this possible?


  2. domokun
    Posted 2 years ago #

    You can pass Form inputs so presumable you can add these to a URL.

    This is how you can pass inputs:

    on_sent_ok: "var name = $('.wpcf7 input[name=your-name]').val();var email = $('.wpcf7 input[name=your-email]').val();$('.wpcf7').hide();$('.entry-title').html('Thank you');$('.entry-content').html(''+name+' : someone from our office will get in touch with you via '+email+' within 24 hours.');"

    And this is how you can redirect to a new URL

    on_sent_ok: "location.replace('http://example.com/thank-you');"

    A good write-up on using both is here: http://www.brianballa.com/contact-form-7-thank-you-success-messages

  3. danicasati
    Posted 2 years ago #

    Thank you for response, but form input should be a part of the redirect URL, not only for generate a custom strings.

    So, text boxes values should be collected to redirect a user to a customized URL.
    Is this possible?

  4. domokun
    Posted 2 years ago #

    Does this work?

    on_sent_ok: "var email = $('.wpcf7 input[name=your-email]').val();location.replace('http://example.com/thank-you?e='+email+'');"

  5. danicasati
    Posted 2 years ago #

    Yes, domoku.
    It works.

    Thank you.
    Just a little problem to read dropdown values if I use this field with pipes: I can read selected item value, but not pipe value.

  6. johnja1
    Posted 2 years ago #

    Hey Domokun,

    I have my on_sent ok to go to Paypal. Will it be possible to validate input field value (eg >2300) and then I want to re-direct to a different url instead of going to the paypal web site.

    Please advice

  7. vivekbavishi
    Posted 2 years ago #

    Hey danicasati,

    Can you please let me know how to use the value of a dropdown input in the custom url

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.