Users::validate_user( string|null $nonce = null )

Handles the request to validate a Zoom user type.


Parameters

$nonce

(string|null) (Optional) The nonce that should accompany the request.

Default value: null


Top ↑

Return

(string) The html from the request containing success or error information.


Top ↑

Source

File: src/Tribe/Meetings/Zoom/Users.php

	public function validate_user( $nonce = null ) {
		if ( ! $this->check_ajax_nonce( static::$validate_user_action, $nonce ) ) {
			return false;
		}

		$event = $this->check_ajax_post();
		if ( empty( $event ) ) {
			$error_message = _x( 'User validation failed because no event was found.', 'The event is missing error message for Zoom user validation.', 'events-virtual' );
			$this->admin_template->template( 'components/message', [
				'message' => $error_message,
				'type'    => 'error',
			] );

			wp_die();
		}

		$zoom_host_id = tribe_get_request_var( 'zoom_host_id' );
		// If no host id found, fail the request.
		if ( empty( $zoom_host_id ) ) {
			$error_message = _x( 'The Zoom Host ID is missing to access the API, please select a host from the dropdown and try again.', 'Host ID is missing error message for Zoom user validation.', 'events-virtual' );
			$this->admin_template->template( 'components/message', [
				'message' => $error_message,
				'type'    => 'error',
			] );

			wp_die();
		}

		$zoom_account_id = tribe_get_request_var( 'zoom_account_id' );
		// If no account id found, fail the request.
		if ( empty( $zoom_account_id ) ) {
			$error_message = _x( 'The Zoom Account ID is missing to access the API.', 'Account ID is missing error message for Zoom user validation.', 'events-virtual' );
			$this->admin_template->template( 'components/message', [
				'message' => $error_message,
				'type'    => 'error',
			] );

			wp_die();
		}

		$account_loaded = $this->api->load_account_by_id( $zoom_account_id );
		// If there is no token, then stop as the connection will fail.
		if ( ! $account_loaded ) {
			$error_message = _x( 'The Zoom Account could not be loaded to access the API. Please try refreshing the account in the Events API Settings.', 'Zoom account loading error message for Zoom user validation.', 'events-virtual' );

			$this->admin_template->template( 'components/message', [
				'message' => $error_message,
				'type'    => 'error',
			] );

			wp_die();
		}

		$settings        = $this->api->fetch_user( $zoom_host_id, true );
		if ( empty( $settings['feature'] ) ) {
			$error_message = _x( 'The Zoom API did not return the user settings. Please try refreshing the account in the Events Integration Settings.', 'Zoom API loading error message for Zoom user validation.', 'events-virtual' );

			$this->admin_template->template( 'components/message', [
				'message' => $error_message,
				'type'    => 'error',
			] );

			wp_die();
		}

		$webinar_support = $this->api->get_webinars_support( $settings );

		/** @var \Tribe\Events\Virtual\Meetings\Zoom\Classic_editor */
		$classic_editor = tribe( Classic_Editor::class );
		$generation_urls = $classic_editor->get_link_creation_urls( $event, $webinar_support );

		$this->admin_template->template(
		'virtual-metabox/zoom/type-options',
			[ 'generation_urls' => $generation_urls, ],
			true
		);

		wp_die();
	}

Top ↑

Changelog

Changelog
Version Description
1.8.2 Introduced.