Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // for http://www.gravityhelp.com/forums/topic/adding-a-link-to-a-dynamic-confirmation-message#post-119604
- // originally http://www.gravityhelp.com/forums/topic/mathematics-to-gravity-forms
- 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'] != 20)
- return $form;
- // 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<=20; $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_25'] = $score;
- switch($score) {
- // my "admin only" Rating field to hold the display message based on the score in input_24
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- $_POST['input_24'] = '5 or fewer correct answers: You\'re a complacent leader who <a href="http://google.com/">ignores changes</a> in the environment.';
- break;
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- $_POST['input_24'] = '6 to 10 correct answers: You\'re a leader who is comfortable with the <a href="http://google.com/">status quo</a>.';
- break;
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- $_POST['input_24'] = '11 to 15 correct answers: You\'re a take charge leader who <a href="http://google.com/">creates their own future</a>.';
- break;
- default:
- $_POST['input_24'] = 'More than 15 correct answers: They\'re ready to produce a reality show about you: "<a href="http://google.com/">Most Admired Leader</a>"';
- }
- return $form;
- }
- // http://www.gravityhelp.com/forums/topic/adding-a-link-to-a-dynamic-confirmation-message#post-115651
- add_filter("gform_allowable_tags_20", "allow_some_html");
- function allow_some_html($allowable_tags){
- return '<p><br><a>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement