Tribe__Tickets__Attendee_Repository::create_attendee_for_ticket( Tribe__Tickets__Ticket_Object|int $ticket, array $attendee_data )

Create an attendee object from ticket and attendee data.


Parameters

$attendee_data

(array) (Required) List of additional attendee data.

$ticket

(Tribe__Tickets__Ticket_Object|int) (Required) The ticket object or ID.


Top ↑

Return

(WP_Post|false) The new post object or false if unsuccessful.


Top ↑

Source

File: src/Tribe/Attendee_Repository.php

	public function create_attendee_for_ticket( $ticket, $attendee_data ) {
		// Attempt to get the ticket object from the ticket ID.
		if ( is_numeric( $ticket ) && $this->attendee_provider ) {
			$ticket = $this->attendee_provider->get_ticket( null, $ticket );
		}

		// Require the ticket be a ticket object.
		if ( ! $ticket instanceof Tribe__Tickets__Ticket_Object ) {
			throw new Tribe__Repository__Usage_Error( 'You must provide a valid ticket ID or object when creating an attendee from the Attendees Repository class' );
		}

		// Set the attendee arguments accordingly.
		$this->set_attendee_args( $attendee_data, $ticket );

		// Update the attendee data for referencing with what we handled in the set_attendee_args().
		$attendee_data = array_merge( $attendee_data, $this->updates );

		// Create the new attendee.
		$attendee = $this->create();

		if ( $attendee ) {
			// Handle any further attendee updates.
			$this->save_extra_attendee_data( $attendee, $attendee_data, $ticket );

			// Trigger creation actions.
			$this->trigger_create_actions( $attendee, $attendee_data, $ticket );
		}

		return $attendee;
	}

Top ↑

Changelog

Changelog
Version Description
5.1.0 Introduced.