Tribe__Tickets_Plus__QR::authorized_checkin( $event_id,  $ticket_id,  $security_code )

Check if user is authorized to Checkin Ticket


Parameters

$event_id

(Required) int event post ID

$ticket_id

(Required) int ticket tost ID

$security_code

(Required) string ticket security code


Top ↑

Return

(array)


Top ↑

Source

File: src/Tribe/QR.php

	public function authorized_checkin( $event_id, $ticket_id, $security_code ) {

		if ( ! is_user_logged_in() || ! current_user_can( 'edit_posts' ) ) {
			$checkin_arr = array(
				'url'             => get_permalink( $event_id ),
				'user_had_access' => false,
			);

			return $checkin_arr;
		}

		$post = get_post( $event_id );

		if ( empty( $post ) ) {
			return array( 'url' => '', 'user_had_access' => true );
		}

		/**
		 * Filters the check for security code when checking in a ticket
		 *
		 * @param false bool the default is not to check security code
		 */
		$check_security_code = apply_filters( 'tribe_tickets_plus_qr_check_security_code', false );

		$service_provider = tribe( 'tickets.data_api' )->get_ticket_provider( $ticket_id );

		//if check_security_code and security key does not match do not checkin and redirect with message
		if ( $check_security_code &&
			(
				empty( $service_provider->security_code ) ||
				$security_code !== get_post_meta( $ticket_id, $service_provider->security_code, true )
			)
		) {

			$url = add_query_arg(
				array(
					'post_type'              => $post->post_type,
					'page'                   => tribe( 'tickets.attendees' )->slug(),
					'event_id'               => $event_id,
					'qr_checked_in'          => $ticket_id,
					'no_security_code_match' => true,
				), admin_url( 'edit.php' )
			);

			$checkin_arr = array(
				'url'             => $url,
				'user_had_access' => true,
			);

			return $checkin_arr;

		}

		// If the user is the site owner (or similar), Check in the user to the event
		$this->_check_in( $ticket_id );

		$url = add_query_arg(
			array(
				'post_type'     => $post->post_type,
				'page'          => tribe( 'tickets.attendees' )->slug(),
				'event_id'      => $event_id,
				'qr_checked_in' => $ticket_id,
			), admin_url( 'edit.php' )
		);

		$checkin_arr = array(
			'url'             => $url,
			'user_had_access' => true,
		);

		return $checkin_arr;
	}

Top ↑

Changelog

Changelog
Version Description
4.8.1 Introduced.