Tribe__Tickets__REST__V1__Main::rest_events_archive_add_attendance( array $data, WP_REST_Request $request )

Filters the data that will be returned for the events endpoint, adding attendance.


Parameters

$data

(array) (Required) The retrieved data.

$request

(WP_REST_Request) (Required) The original request.


Top ↑

Return

(array) $data The retrieved data, updated with attendance if the request has access.


Top ↑

Source

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

	public function rest_events_archive_add_attendance( $data, $request ) : array {

		if ( ! $this->request_has_manage_access() ) {
			return $data;
		}

		if ( empty( $data['events'] ) ) {
			return $data;
		}

		foreach ( $data['events'] as $event ) {
			$event_id       = is_array( $event ) ? $event['id'] : $event->id;
			$attendee_count = Tribe__Tickets__Tickets::get_event_attendees_count( $event_id );
			$checked_in     = Tribe__Tickets__Tickets::get_event_checkedin_attendees_count( $event_id );

			$event['attendance'] = [
				'total_attendees' => $attendee_count,
				'checked_in'      => $checked_in,
				'not_checked_in'  => $attendee_count - $checked_in,
			];

		}

		return $data;
	}

Top ↑

Changelog

Changelog
Version Description
5.5.2 Introduced.