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.

Redirect on multiple conditions

  1. I have read a few similar threads but do not know enough about coding to apply to my situation...

    My form is on http://www.precisionfirst.com/test/

    I have a short (3 question) survey that I send customers to. There are 3 possible answers to each (very pleased, somewhat pleased, not at all pleased).

    If customers are unhappy I simply want to say "thank you." If they are happy, I would like to redirect them to a review page. Right now, I have conditional formatting set up to show the link (using an HTML box) only if none of the answers are "not pleased at all" (and an email address is entered). However, the link takes them away from the survey before they hit submit... I would like to only redirect AFTER they hit submit. Can someone point me in the right direction to code a rule that displays a simple message if ANY of the answers were "not pleased at all" and redirects to http://www.precisionfirst.com/review if NONE of the answers were "not pleased at all."

    Thanks,

    Posted 11 years ago on Thursday January 24, 2013 | Permalink
  2. David Peralty

    This is the filter you would use in your theme's functions.php file:
    http://www.gravityhelp.com/documentation/page/Gform_confirmation

    Instead of testing for one thing per if statement, you would check all three. And if all three are the value you want, then you can have it redirect like in our example on that documentation page.

    Posted 11 years ago on Thursday January 24, 2013 | Permalink
  3. Thanks for help. The problem I am having with that is I want to redirect them if even one answer is negative, it does not have to be all three. Is the filter capable of doing an "or" type statement?

    i.e. (tailored to my situation)
    if($form["2"] == "Not as quickly as I expected.") OR ($form["3"] == "Not as helpful as I'd have liked.") OR ($form["4"] == "Not fully satisfied. "){
    $confirmation = "Thanks for contacting us. We will get in touch with you soon";
    }
    else{
    $confirmation = array("redirect" =>"http://www.mysite.com/review");
    }

    Posted 11 years ago on Thursday January 24, 2013 | Permalink
  4. David Peralty

    Check out this conversation about using PHP to do if/and/or statements - http://www.codingforums.com/archive/index.php/t-85464.html

    Posted 11 years ago on Thursday January 24, 2013 | Permalink
  5. Thanks for that!

    Currently I have this for code: http://pastie.org/5849981

    I got the redirect to work but it is working all the time and seems to be skipping past the "if" part. Now I cannot get it to display my text response even if there are negative answers.

    Lastly, I wanted to verify where the code should be inserted. Above, you say in the theme's function.php file but on the documentation page you referenced it says "This filter is located in form_display.php" Which is it?

    Thanks again!

    Posted 11 years ago on Thursday January 24, 2013 | Permalink
  6. The code goes in your theme's functions.php. The "This filter is located in form_display.php" is an explanation of where the code is in the source if you want to take a closer look. Your code goes in your theme's functions.php.

    Line 4 in your code is incorrect. You probably want to check $lead, not $form, since you are already working with form 4 based on your add_action in line 2.

    [php]
    if(($lead["2"] == "Not as quickly as I expected.") || ($lead["3"] == "Not as helpful as I'd have liked.") || ($lead["4"] == "Not fully satisfied.")){

    That would check the answers to questions 2, 3 and 4 and compare them to the strings, and if any of them match, you get the confirmation on line 5. Otherwise, you get the confirmation on line 8.

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink