Advertisement
chrishajer

Allowable tags filter

Jan 11th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. // for http://www.gravityhelp.com/forums/topic/adding-a-link-to-a-dynamic-confirmation-message#post-119604
  2. // originally http://www.gravityhelp.com/forums/topic/mathematics-to-gravity-forms
  3. add_action('gform_pre_submission', 'ch_total_quiz_values');
  4. function ch_total_quiz_values ($form) {
  5.     // change the number 20 here to your form ID
  6.     // if this is not form 20, don't do any processing
  7.     if($form['id'] != 20)
  8.         return $form;
  9.  
  10.     // otherwise ...
  11.     $score = 0;
  12.     // my radio button inputs are numbered 1 to 20.  Change the beginning
  13.     // and ending number in this loop to match your actual input numbers
  14.     for($i=1; $i<=20; $i++) {
  15.         // add the value of the $_POST value for input 1 to input 20
  16.         $input  = 'input_' . $i;
  17.         $score += rgpost($input);
  18.     }
  19.     // update the hidden 'Score' field with our calculated score
  20.     $_POST['input_25'] = $score;
  21.     switch($score) {
  22.         // my "admin only" Rating field to hold the display message based on the score in input_24
  23.         case 0:
  24.         case 1:
  25.         case 2:
  26.         case 3:
  27.         case 4:
  28.         case 5:
  29.             $_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.';
  30.             break;
  31.         case 6:
  32.         case 7:
  33.         case 8:
  34.         case 9:
  35.         case 10:
  36.             $_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>.';
  37.             break;
  38.         case 11:
  39.         case 12:
  40.         case 13:
  41.         case 14:
  42.         case 15:
  43.             $_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>.';
  44.             break;
  45.         default:
  46.             $_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>"';
  47.     }
  48.     return $form;
  49. }
  50.  
  51. // http://www.gravityhelp.com/forums/topic/adding-a-link-to-a-dynamic-confirmation-message#post-115651
  52. add_filter("gform_allowable_tags_20", "allow_some_html");
  53. function allow_some_html($allowable_tags){
  54.     return '<p><br><a>';
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement