Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'gform_pre_submission_filter_1', 'gf_adobe_register' );
- function gf_adobe_register( $form ) {
- //exit( var_dump( $_POST ) );
- $first_name = $_POST['input_1_3'];
- $last_name = $_POST['input_1_6'];
- $full_name = sprintf( '%s %s ', $first_name, $last_name );
- $email_address = $_POST['input_3'];
- $password = $_POST['input_17'];
- $webinar_id = $_POST['input_18']; //webinar_id hidden field
- // get the sco_id
- $sco_id = get_post_meta( $webinar_id, 'sco_id', TRUE );
- $client = new AdobeConnectClient( AC_HOST, AC_USERNAME, AC_PASSWORD );
- // Authenticate with Adobe Connect
- if( $client->makeAuth() ) {
- // Does email exist?
- if( !$client->getUserByEmail( $email_address, true ) ) {
- // Create the user
- if( !$client->createUser( $email_address, $password, $full_name ) ) {
- $form['confirmation'] = 'Sorry we could not register you for the webinar.';
- log_error( sprintf( 'Could not create user: %s, %s', $full_name, $email_address ) );
- // send error message to admin
- GFCommon::log_debug( $form . ' could not create user.' );
- }
- }
- // check if they've already been invited
- if( !$client->getMeetingAttendees( $sco_id, $email_address ) ) {
- // add user to meeting
- if( !$client->inviteUserToMeeting($sco_id, $email_address ) ) {
- $form['confirmation'] = 'Sorry we could not register you for the webinar';
- log_error( sprintf( 'Could not invite user to meeting: %s, %s', $full_name, $email_address ) );
- // send error message to admin
- GFCommon::log_debug( $form . ' could not invite user.' );
- }
- }
- else {
- $form['confirmation'] = 'You\'ve already been invited to this webinar';
- log_error( sprintf( 'Could not invite user to meeting: %s, %s', $full_name, $email_address ) );
- GFCommon::log_debug( $form . ' user already invited.' );
- }
- }
- else {
- // Error: could not authenticate
- $form['confirmation'] = 'Sorry we could not register you for the webinar. Please try again later.';
- log_error( 'Could not authenticate with Adbobe Connect.' );
- // send error message to admin
- GFCommon::log_debug( $form . ' could not authenticate.' );
- }
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement