Advertisement
HarunRRayhan

Get Quiz Field Title & Quiz Score

Jun 2nd, 2017
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. add_action( 'gform_after_submission_3', 'hrx_bigshot_after_submission', 10, 2 );
  2. function hrx_bigshot_after_submission( $entry, $form ) {
  3.     global $wpdb;
  4.  
  5.     // Quiz Score Calculation
  6.     $quiz_score = $entry['gquiz_score'];
  7.  
  8.     $analyze_text = '';
  9.  
  10.     if($quiz_score > 150 &&  $quiz_score <= 220) {
  11.         $analyze_text = $entry[40];
  12.     } elseif ($quiz_score > 220 &&  $quiz_score <= 290) {
  13.         $analyze_text = $entry[41];
  14.     } elseif ($quiz_score > 290) {
  15.         $analyze_text = $entry[42];
  16.     }
  17.  
  18.     $wpdb->update(
  19.         $wpdb->prefix."rg_lead_detail",
  20.         array('value' => $analyze_text),
  21.         array('field_number' => 43,
  22.             'lead_id' => $entry['id'],
  23.             'form_id' => 3
  24.         )
  25.     );
  26.  
  27.  
  28.     // Get Selected Quiz Title to send 3rd party or other form
  29.     $quiz_1 = 4;
  30.     $answer_1 = 45;
  31.  
  32.     $field_1 = GFFormsModel::get_field( $form, $quiz_1);
  33.     $choice_label_1 = $field_1->get_value_export( $entry, $quiz_1, true );
  34.     $wpdb->update(
  35.         $wpdb->prefix."rg_lead_detail",
  36.         // array('value' => print_r($form, true)),
  37.         array('value' => $choice_label_1),
  38.         array('field_number' => $answer_1,
  39.             'lead_id' => $entry['id'],
  40.             'form_id' => 3
  41.         )
  42.     );
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement