Tribe__Tickets__Tickets_View::get_event_attendees_by_order( int $event_id, int|null $user_id = null, boolean $include_rsvp = false )
Fetches from the Cached attendees list the ones that are relevant for this user and event.
Contents
Important to note that this method will return the attendees organized by order id.
Parameters
- $event_id
-
(int) (Required) The Event ID we're checking.
- $user_id
-
(int|null) (Optional) An Optional User ID.
Default value: null
- $include_rsvp
-
(boolean) (Optional) If this should include RSVP,
Default value: false
Return
(array) List of Attendees grouped by order id.
Source
File: src/Tribe/Tickets_View.php
public function get_event_attendees_by_order( $event_id, $user_id = null, $include_rsvp = false ) {
if ( ! $user_id ) {
$attendees = Tribe__Tickets__Tickets::get_event_attendees( $event_id );
} else {
// If we have a user_id then limit by that.
$args = [
'by' => [
'user' => $user_id,
],
];
$attendee_data = Tribe__Tickets__Tickets::get_event_attendees_by_args( $event_id, $args );
$attendees = $attendee_data['attendees'];
}
$orders = array();
foreach ( $attendees as $key => $attendee ) {
// Ignore RSVP if we don't tell it specifically
if ( 'rsvp' === $attendee['provider_slug'] && ! $include_rsvp ) {
continue;
}
$orders[ (int) $attendee['order_id'] ][] = $attendee;
}
return $orders;
}