Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.goracertech.com/blog/spring-selector/
- add_action('gform_pre_submission', 'ch_total_quiz_values');
- function ch_total_quiz_values ($form) {
- // change the number 20 here to your form ID
- // if this is not form 20, don't do any processing
- if($form['id'] != 4)
- return $form;
- // get RZR model
- $rzr_model = $_POST['input_1'];
- // normalize rzr model to score value
- if($rzr_model == 5) {
- $_POST['input_1'] = -300; // RZR 4 800
- }
- // otherwise ...
- $score = 0;
- // my radio button inputs are numbered 1 to 20. Change the beginning
- // and ending number in this loop to match your actual input numbers
- for($i=1; $i<=19; $i++) {
- // add the value of the $_POST value for input 1 to input 20
- $input = 'input_' . $i;
- $score += rgpost($input);
- }
- // update the hidden 'Score' field with our calculated score
- $_POST['input_20'] = $score;
- // set the recommendation
- if($score < 400) {
- $_POST['input_21'] = 'MEDIUM RATE';
- }
- else {
- $_POST['input_21'] = 'HEAVY RATE';
- }
- // set the recommendation link
- switch($rzr_model) {
- case 1: // RZR 800 50 inch STD
- $_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>.");
- break;
- case 2: // RZR 800 50 inch Walker evans edition
- $_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>.");
- break;
- case 3: // RZR S 800 with fox podium shocks
- $_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>.");
- break;
- case 4: // RZR S 800 with sachs shocks
- $_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>.");
- break;
- case 5: // RZR 4 800
- $_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>.");
- break;
- case 6: // RZR XP 900
- $_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>.");
- break;
- }
- return $form;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement