Advertisement
chrishajer

Conditional Confirmation

Aug 27th, 2011
998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. // http://www.gravityhelp.com/forums/topic/making-a-result-page-based-on-conditional-logic
  2. // change the 15 below to your form ID
  3. add_filter('gform_confirmation_15', 'ch_build_confirmation', 10, 4);
  4. function ch_build_confirmation ($confirmation, $form, $lead, $ajax) {
  5.         // initialize the confirmation message
  6.         $confirmation  = "<div id='gforms_confirmation_message' style='text-align:left; padding: 10px;'><p>Thank you for your
  7. candid answers.  Here's what we think after reviewing your entries.</p>";
  8.  
  9.         // $lead[1] is the color choice question.  I used values of "c, m, y, k, r, g, b"
  10.         $confirmation .= '<p>What your <strong>color choice</strong> says about you: ';
  11.         $rgb  = array('r', 'g', 'b');
  12.         $cmyk = array('c', 'm', 'y', 'k');
  13.         if(in_array($lead[1], $rgb))
  14.                 $confirmation .= "you're a Photoshop person, comfortable in the digital world of RGB.</p>";
  15.         else if(in_array($lead[1], $cmyk))
  16.                 $confirmation .= "you're a print person, happy around paper and ink.</p>";
  17.         else
  18.                 // this will catch errors if an entered value was not accounted for in our arrays
  19.                 $confirmation .= "doesn't say much about you at all.</p>";
  20.  
  21.         // $lead[2] is the "appreciation vs accomplish" question
  22.         $confirmation .= '<p><strong>What motivates you?</strong> ';
  23.         if($lead[2] == 'Being appreciated')
  24.                 $confirmation .= "Being appreciated?  That's sad and pathetic.</p>";
  25.         else if($lead[2] == 'Getting results')
  26.                 $confirmation .= "That's more like it sparky.  We're looking for results on this team.</p>";
  27.         else
  28.                 // account for values not being entered somehow
  29.                 $confirmation .= "You're not really motivated are you? We've seen your type before.</p>";
  30.  
  31.         // $lead[3] is the "experience vs. gut" question
  32.         $confirmation .= '<p>What do you <strong>trust</strong>? ';
  33.         if($lead[3] == 'Actual experience')
  34.                 $confirmation .= 'Experience.  We like that.</p>';
  35.         else if($lead[3] == 'Gut instinct')
  36.                 $confirmation .= 'Your gut?  Seriously?</p>';
  37.         else
  38.                 $confirmation .= "You don't trust much do you?</p>";
  39.  
  40.         // close the confirmation message
  41.         $confirmation .= "</div>";
  42.         return $confirmation;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement