Advertisement
Guest User

Updated Adobe Connect

a guest
Apr 6th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <?php
  2.  
  3. add_filter( 'gform_pre_submission_filter_1', 'gf_adobe_register' );
  4.  
  5. function gf_adobe_register( $form ) {
  6.    
  7.     //exit( var_dump( $_POST ) );
  8.    
  9.     $first_name = $_POST['input_1_3'];
  10.     $last_name =  $_POST['input_1_6'];
  11.     $full_name = sprintf( '%s %s ', $first_name, $last_name );
  12.     $email_address = $_POST['input_3'];
  13.     $password = $_POST['input_17'];
  14.    
  15.     $webinar_id = $_POST['input_18']; //webinar_id hidden field
  16.        
  17.     // get the sco_id
  18.     $sco_id = get_post_meta( $webinar_id, 'sco_id', TRUE );
  19.    
  20.     $client = new AdobeConnectClient( AC_HOST, AC_USERNAME, AC_PASSWORD );
  21.        
  22.     // Authenticate with Adobe Connect
  23.     if( $client->makeAuth() ) {
  24.                
  25.        
  26.         // Does email exist?
  27.         if( !$client->getUserByEmail( $email_address, true ) ) {
  28.             // Create the user
  29.             if( !$client->createUser( $email_address, $password, $full_name ) ) {
  30.                 $form['confirmation'] = 'Sorry we could not register you for the webinar.';
  31.                 log_error( sprintf( 'Could not create user: %s, %s', $full_name, $email_address ) );
  32.                 // send error message to admin
  33.                 GFCommon::log_debug( $form . ' could not create user.' );
  34.                
  35.             }
  36.         }
  37.        
  38.         // check if they've already been invited
  39.         if( !$client->getMeetingAttendees( $sco_id, $email_address ) ) {
  40.            
  41.             // add user to meeting
  42.             if( !$client->inviteUserToMeeting($sco_id, $email_address ) ) {
  43.                
  44.                 $form['confirmation'] = 'Sorry we could not register you for the webinar';
  45.                 log_error( sprintf( 'Could not invite user to meeting: %s, %s', $full_name, $email_address ) );
  46.                 // send error message to admin
  47.                 GFCommon::log_debug( $form . ' could not invite user.' );              
  48.             }
  49.            
  50.         }
  51.         else {
  52.             $form['confirmation'] = 'You\'ve already been invited to this webinar';
  53.             log_error( sprintf( 'Could not invite user to meeting: %s, %s', $full_name, $email_address ) );
  54.            
  55.             GFCommon::log_debug( $form . ' user already invited.' );
  56.         }
  57.        
  58.        
  59.     }
  60.     else {
  61.    
  62.         // Error: could not authenticate
  63.         $form['confirmation'] = 'Sorry we could not register you for the webinar. Please try again later.';
  64.         log_error( 'Could not authenticate with Adbobe Connect.' );
  65.         // send error message to admin
  66.         GFCommon::log_debug( $form . ' could not authenticate.' );
  67.        
  68.     }
  69.        
  70.     return $form;
  71.    
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement