Gotowebinar_Helpers::gtw_unregister_user( string $user_id, string $webinar_key,  $action_data = null )

For un-registering user to webinar action method.


Parameters Parameters

$user_id

(Required)

$webinar_key

(Required)


Top ↑

Return Return

(array)


Source Source

File: src/integrations/gotowebinar/helpers/gotowebinar-helpers.php

	public function gtw_unregister_user( $user_id, $webinar_key, $action_data = null ) {

		list( $access_token, $organizer_key ) = $this->get_webinar_token();

		$user_registrant_key = get_user_meta( $user_id, '_uncannyowl_gtw_webinar_' . $webinar_key . '_registrantKey', true );

		if ( empty( $user_registrant_key ) ) {
			throw new \Exception( __( 'User was not registered for webinar.', 'uncanny-automator' ) );
		}

		$params = array(
			'url' => "https://api.getgo.com/G2W/rest/v2/organizers/{$organizer_key}/webinars/{$webinar_key}/registrants/{$user_registrant_key}",
			'method'      => 'DELETE',
			'timeout'     => 45,
			'redirection' => 5,
			'httpversion' => '1.0',
			'blocking'    => true,
			'headers'     => array(
				'Authorization' => $access_token,
				'Content-type'  => 'application/json',
			),
		);

		$response = $this->remote_request( $params, $action_data );

		$code = wp_remote_retrieve_response_code( $response );

		if ( 201 !== $code && 204 !== $code ) {
			$jsondata = json_decode( $response['body'], true, 512, JSON_BIGINT_AS_STRING );
			throw new \Exception( esc_html( $jsondata['description'] ) );
		}

		delete_user_meta( $user_id, '_uncannyowl_gtw_webinar_' . $webinar_key . '_registrantKey' );
		delete_user_meta( $user_id, '_uncannyowl_gtw_webinar_' . $webinar_key . '_joinUrl' );
	}