PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Quiz with conditional re-direct

  1. I need to re-create this quiz: http://ecogenics.com/skincare_profile.htm
    which I did using ASP. Each radio button choice is assigned a number 1-4 then added. The total redirects to one of 3 different pages.

    I thought I could do this based on the description of the latest Gravity forms update but I don't see field calculation options and the submit form redirect only takes a single URL.

    Is this possible?

    Posted 11 years ago on Tuesday July 24, 2012 | Permalink
  2. You can do this but it will require a bit of PHP added to your theme's functions.php.

    You can use radio buttons for your fields, and assign values to each of the radio button choices for each field. Then in your theme's functions.php, you can total all the radio button selections, and change the redirect URL based on the total. You can use the gform_confirmation filter to change the redirect URL. Please see the example here:

    http://www.gravityhelp.com/documentation/page/Gform_confirmation

    Posted 11 years ago on Tuesday July 24, 2012 | Permalink
  3. I understand the example for redirecting but how do I add up the field numbers and conditionally re-direct based on the total?

    Posted 11 years ago on Wednesday July 25, 2012 | Permalink
  4. You need to do the math in your theme's functions.php. Your function will be hooked to the gform_confirmation filter. So, when it comes time for the plugin to deal with the form confirmation, that filter is called, and your function says "OK, add up the inputs from these radio button fields and if the result is:

    greater than 21, confirmation page one
    greater than 14, confirmation page two
    greater than 7, confirmation page three
    default (less than 7), confirmation page four

    You can use a PHP case statement. So, first, total the input values. Second, change the confirmation page based on the aggregate score. Third, return that confirmation page.

    Posted 11 years ago on Wednesday July 25, 2012 | Permalink
  5. Here is a little bit of an example I wrote a while back showing how to add the values and use them conditionally. I used them to change the confirmation text, but you can use the same procedure to change the confirmation redirect URL.

    http://pastebin.com/uz7VX2NP

    Posted 11 years ago on Wednesday July 25, 2012 | Permalink