Tribe__Tickets__REST__V1__Post_Repository::get_attendee_data( $attendee_id,  $context = 'default' )

{@inheritdoc}

Contents


Source

File: src/Tribe/REST/V1/Post_Repository.php

	public function get_attendee_data( $attendee_id, $context = 'default' ) {
		$attendee_post = get_post( $attendee_id );

		if ( ! $attendee_post instanceof WP_Post ) {
			// the attendee post does not exist, user error
			return new WP_Error( 'attendee-not-found', $this->messages->get_message( 'attendee-not-found' ), array( 'status' => 404 ) );
		}

		$attendee_id = $attendee_post->ID;

		/** @var Tribe__Tickets__Data_API $data_api */
		$data_api = tribe( 'tickets.data_api' );
		/** @var Tribe__Tickets__Tickets $provider */
		$provider = $data_api->get_ticket_provider( $attendee_id );

		if ( false === $provider ) {
			// the attendee post does exist but it does not make sense on the server, server error
			return new WP_Error( 'attendee-not-found', $this->messages->get_message( 'attendee-not-found' ), array( 'status' => 500 ) );
		}

		// The return value of this function will always be an array even if we only want one object.
		$attendee = $provider->get_all_attendees_by_attendee_id( $attendee_id );

		if ( empty( $attendee ) ) {
			// the attendee post does exist but it does not make sense on the server, server error
			return new WP_Error( 'attendee-not-found', $this->messages->get_message( 'attendee-not-found' ), array( 'status' => 500 ) );
		}

		// See note above, this is an array with one element in it
		$attendee = $attendee[0];

		return $this->build_attendee_data( $attendee );
	}

Top ↑

Changelog

Changelog
Version Description
4.12.0 Introduced.