Tribe__Tickets__REST__V1__Post_Repository::get_qr_data( int $attendee_id, string $context = '' )
Returns an array representation of an attendee.
Contents
Parameters
- $attendee_id
-
(int) (Required) A attendee post ID.
- $context
-
(string) (Optional) Context of data.
Default value: ''
Return
(array|WP_Error) Either the array representation of an attendee or an error object.
Source
File: src/Tribe/REST/V1/Post_Repository.php
public function get_qr_data( $attendee_id, $context = '' ) {
/** @var Tribe__Tickets__Data_API $data_api */
$data_api = tribe( 'tickets.data_api' );
$attendee = get_post( $attendee_id );
$attendee_type = $data_api->detect_by_id( $attendee_id );
if ( empty( $attendee ) || empty( $attendee_type['class'] ) ) {
return new WP_Error( 'attendee-not-found', $this->messages->get_message( 'attendee-not-found' ) );
}
$service_provider = $data_api->get_ticket_provider( $attendee_id );
if ( empty( $service_provider->checkin_key ) ) {
return new WP_Error( 'attendee-check-in-not-found', $this->messages->get_message( 'attendee-check-in-not-found' ) );
}
$meta = array_map( 'reset', get_post_custom( $attendee_id ) );
$data = [
'id' => $attendee_id,
'checked_in' => isset( $meta[ $service_provider->checkin_key ] ) ? $meta[ $service_provider->checkin_key ] : '',
];
/**
* Filters the data that will be returned for a single attendee.
*
* @since 4.7.5
* @deprecated 5.7.0 Use `tribe_tickets_rest_qr_data` instead.
*
* @param array $data The data that will be returned in the response.
* @param WP_Post $attendee The requested attendee.
*/
$data = apply_filters_deprecated( 'tribe_tickets_plus_rest_qr_data', [ $data, $attendee ], '5.7.0', 'tribe_tickets_rest_qr_data' );
/**
* Filters the data that will be returned for a single attendee.
*
* @since 5.7.0
*
* @param array $data The data that will be returned in the response.
* @param WP_Post $attendee The requested attendee.
*/
$data = apply_filters( 'tribe_tickets_rest_qr_data', $data, $attendee );
return $data;
}
Changelog
| Version | Description |
|---|---|
| 5.7.0 | Introduced. |