コード例 #1
0
 /**
  * Register the consumer with the webinar. Returns and error if unable to register
  * @param $confirmation The confirmation string set in the Gravity Form GUI
  * @param $form - The Gravity Forms form object
  * @param $entry - The user submitted entry
  * @return string - the modified confirmation
  */
 public function webinar_form_confirmation($confirmation, $form, $entry)
 {
     // Filter the user data, and map it a format that the Citrix Expects
     $citrix_data = $this->map_citrix_data($form['fields'], $entry);
     // Get the webinar key from the entry data -- use the entry data because a notification can be forced
     // after the inital submission, should the Citrix API fail.
     $webinar_key = $this->get_citrix_key_from_fields($form['fields'], $entry);
     // Register the User with the Citrix API
     $webinarClient = new WebinarClient();
     $response = $webinarClient->register($webinar_key, $citrix_data);
     // Check for errors
     if ($response['has_errors']) {
         // Get the Admin Options for the Citrix Connect Webinar
         $options = get_option('citrix-connect-webinar');
         //Notifiy the admin of failed registration
         $this->sendErrorEmail($response, $citrix_data, 'webinar');
         // Check if an error message has been set via the Admin Menu
         if (empty($options['webinar_error'])) {
             $errors = '';
             foreach ($response['errors'] as $error) {
                 $errors .= "<p>" . $error . "</p>";
             }
             $confirmation = $errors . "<p>Unfortunately, we were unable to register you for this webinar. Your registration information has been saved, and an administrator has been notified.</p>\n             <p>We will reach out to you shortly regarding your registration. Thank you for your patience.</p>";
         } else {
             $confirmation = $options['webinar_error'];
         }
     } else {
     }
     return $confirmation;
 }