Zoom_Webinar_Helpers::unregister_user( string $email, string $webinar_key )

For un-registering user to webinar action method.


Parameters Parameters

$email

(string) (Required)

$webinar_key

(string) (Required)


Top ↑

Return Return

(array)


Source Source

File: src/integrations/zoom-webinar/helpers/zoom-webinar-helpers.php

	public function unregister_user( $email, $webinar_key ) {

		$client = $this->get_client();

		if ( ! $client || empty( $client['access_token'] ) ) {
			return array(
				'result'  => false,
				'message' => __( 'Zoom Webinar credentails have expired.', 'uncanny-automator' ),
			);
		}

		$response = wp_remote_post(
			$this->automator_api,
			array(
				'body' =>
					array(
						'action'       => 'unregister_webinar_user',
						'access_token' => $client['access_token'],
						'webinar_key'  => $webinar_key,
						'email'        => $email,
					),
			)
		);

		if ( ! is_wp_error( $response ) ) {

			if ( 201 === wp_remote_retrieve_response_code( $response ) || 204 === wp_remote_retrieve_response_code( $response ) ) {

				return array(
					'result'  => true,
					'message' => __( 'Successfully registered', 'uncanny-automator' ),
				);

			} else {

				$body = json_decode( wp_remote_retrieve_body( $response ), true );

				$error = '';

				if ( isset( $body['data']['message'] ) ) {
					$error = $body['data']['message'];
				} elseif ( isset( $body['error']['description'] ) ) {
					$error = $body['error']['description'];
				}

				return array(
					'result'  => false,
					'message' => __( $error, 'uncanny-automator' ),
				);
			}
		}

		return array(
			'result'  => false,
			'message' => __( 'WordPress was not able to communicate with Zoom API.', 'uncanny-automator' ),
		);
	}