Tribe__Tickets__RSVP::checkin( int $attendee_id, bool|null $qr = null, int|null $event_id = null )
Marks an attendee as checked in for an event
Contents
Because we must still support our legacy ticket plugins, we cannot change the abstract checkin() method’s signature. However, the QR checkin process needs to move forward so we get around that problem by leveraging func_get_arg() to pass a second argument.
It is hacky, but we’ll aim to resolve this issue when we end-of-life our legacy ticket plugins OR write around it in a future major release
Parameters
- $attendee_id
-
(int) (Required) The Attendee ID.
- $qr
-
(bool|null) (Optional) True if from QR checkin process.
Default value: null
- $event_id
-
(int|null) (Optional) The ID of the ticket-able post the Attendee is being checked into.
Default value: null
Return
(bool)
Source
File: src/Tribe/RSVP.php
public function checkin( $attendee_id ) {
$qr = null;
$args = func_get_args();
if ( isset( $args[1] ) && $qr = (bool) $args[1] ) {
update_post_meta( $attendee_id, '_tribe_qr_status', 1 );
}
$event_id = get_post_meta( $attendee_id, self::ATTENDEE_EVENT_KEY, true );
if ( ! $qr && ! tribe( 'tickets.attendees' )->user_can_manage_attendees( 0, $event_id ) ) {
return false;
}
update_post_meta( $attendee_id, $this->checkin_key, 1 );
if ( func_num_args() > 1 && $qr = func_get_arg( 1 ) ) {
update_post_meta( $attendee_id, '_tribe_qr_status', 1 );
}
$checkin_details = array(
'date' => current_time( 'mysql' ),
'source' => null !== $qr ? 'app' : 'site',
'author' => get_current_user_id(),
);
/**
* Filters the checkin details for this attendee checkin.
*
* @since 4.8
*
* @param array $checkin_details
* @param int $attendee_id
* @param mixed $qr
*/
$checkin_details = apply_filters( 'rsvp_checkin_details', $checkin_details, $attendee_id, $qr );
update_post_meta( $attendee_id, $this->checkin_key . '_details', $checkin_details );
/**
* Fires a checkin action
*
* @var int $attendee_id
* @var bool|null $qr
*/
do_action( 'rsvp_checkin', $attendee_id, $qr );
return true;
}