G2A Many GEOs
SHARE
TWEET

Syntax errors corrected

a guest Jan 6th, 2013 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // http://www.goracertech.com/blog/spring-selector/
  2. add_action('gform_pre_submission', 'ch_total_quiz_values');
  3. function ch_total_quiz_values ($form) {
  4.         // change the number 20 here to your form ID
  5.         // if this is not form 20, don't do any processing
  6.         if($form['id'] != 4)
  7.                 return $form;
  8.  
  9.         // get RZR model
  10.         $rzr_model = $_POST['input_1'];
  11.  
  12.         // normalize rzr model to score value
  13.         if($rzr_model == 5) {
  14.                 $_POST['input_1'] = -300; // RZR 4 800
  15.         }
  16.  
  17.         // otherwise ...
  18.         $score = 0;
  19.  
  20.         // my radio button inputs are numbered 1 to 20.  Change the beginning
  21.         // and ending number in this loop to match your actual input numbers
  22.         for($i=1; $i<=19; $i++) {
  23.                 // add the value of the $_POST value for input 1 to input 20
  24.                 $input  = 'input_' . $i;
  25.                 $score += rgpost($input);
  26.         }
  27.  
  28.         // update the hidden 'Score' field with our calculated score
  29.         $_POST['input_20'] = $score;
  30.  
  31.         // set the recommendation
  32.         if($score < 400) {
  33.                 $_POST['input_21'] = 'MEDIUM RATE';
  34.         }
  35.         else {
  36.                 $_POST['input_21'] = 'HEAVY RATE';
  37.         }
  38.  
  39.         // set the recommendation link
  40.         switch($rzr_model) {
  41.                 case 1: // RZR 800 50 inch STD
  42.                         $_POST['input_23'] = nl2br("Standard RZR 50 inch Replacement Springs Kit.\r\n<a href='http://www.goracertech.com/rzr-std-replacement-springs.html'>Buy them here</a>.");
  43.                         break;
  44.                 case 2: // RZR 800 50 inch Walker evans edition
  45.                         $_POST['input_23'] = nl2br("Standard RZR 50 inch Replacement Springs Kit.\r\n<a href='http://www.goracertech.com/rzr-std-replacement-springs.html'>Buy them here</a>.");
  46.                         break;
  47.                 case 3: // RZR S 800 with fox podium shocks
  48.                         $_POST['input_23'] = nl2br("RZR S Replacement Springs Kit - Fox Podium Dual Rate\r\n<a href='http://www.goracertech.com/rzr-s-replacement-springs.html'>Buy them here</a>.");
  49.                         break;
  50.                 case 4: // RZR S 800 with sachs shocks
  51.                         $_POST['input_23'] = nl2br("RZR S Sachs Replacement Springs - 2011+ RZR S\r\n<a href='http://www.goracertech.com/rzr-s-sachs-replacement-springs-2011-rzr-s.html'>Buy them here</a>.");
  52.                         break;
  53.                 case 5: // RZR 4 800
  54.                         $_POST['input_23'] = nl2br("RZR 4 800 Replacement Springs Kit - Dual Rate\r\n<a href='http://www.goracertech.com/rzr-4-replacement-springs.html'>Buy them here</a>.");
  55.                         break;
  56.                 case 6: // RZR XP 900
  57.                         $_POST['input_23'] = nl2br("RZR XP 900 Dual Rate Springs Replacement Kit\r\n<a href='http://www.goracertech.com/products/featured/rzr-xp-900-dual-rate-spring-replacement-kit.html'>Buy them here</a>.");
  58.                         break;
  59.         }
  60.  
  61.         return $form;
  62. }
  63. ?>
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top