Zoom_Helpers::register_userless( string $user, string $meeting_key )

For registering a user to meeting action method.


Parameters Parameters

$user

(Required)

$meeting_key

(Required)


Top ↑

Return Return

(array)


Source Source

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

	public function register_userless( $user, $meeting_key ) {
		$customer_email       = $user['EMAIL'];
		$customer_email_parts = explode( '@', $customer_email );
		$customer_first_name = empty( $user['FIRSTNAME'] ) ? $customer_email_parts[0] : $user['FIRSTNAME'];
		$customer_last_name  = empty( $user['LASTNAME'] ) ? $customer_email_parts[0] : $user['LASTNAME'];
		$client = $this->get_client();
		if ( ! $client || empty( $client['access_token'] ) ) {
			return array(
				'result'  => false,
				'message' => __( 'Zoom credentials have expired.', 'uncanny-automator' ),
			);
		}
		$response = wp_remote_post(
			$this->automator_api,
			array(
				'body' =>
					array(
						'action'       => 'register_meeting_user',
						'access_token' => $client['access_token'],
						'meeting_key'  => $meeting_key,
						'first_name'   => $customer_first_name,
						'last_name'    => $customer_last_name,
						'email'        => $customer_email,
					),
			)
		);
		if ( ! is_wp_error( $response ) ) {
			$body = json_decode( wp_remote_retrieve_body( $response ), true );
			if ( 201 === wp_remote_retrieve_response_code( $response ) ) {
				if ( isset( $body['data']['join_url'] ) ) {
					return array(
						'result'  => true,
						'message' => __( 'Successfully registered', 'uncanny-automator' ),
					);
				}
			} else {
				$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' ),
		);
	}