Tribe__Tickets_Plus__QR::handle_redirects()

Processes the links coming from QR codes and decides what to do: – If the user is logged in and has proper permissions, it will redirect to the attendees screen for the event, and will automatically check in the user.

  • If the user is not logged in and/or does not have proper permissions, it will redirect to the homepage of the event (front end single event view).

Source

File: src/Tribe/QR.php

	public function handle_redirects() {

		// Check if it's our time to shine.
		// Not as fancy as a custom permalink handler, but way less likely to fail depending on setup and settings
		if ( ! isset( $_GET['event_qr_code'] ) ) {
			return;
		}

		// Check all the data we need is there
		if ( empty( $_GET['ticket_id'] ) || empty( $_GET['event_id'] ) ) {
			return;
		}

		// Make sure we don't fail too hard
		if ( ! class_exists( 'Tribe__Tickets__Tickets_Handler' ) ) {
			return;
		}


		$event_id      = (int) $_GET['event_id'];
		$ticket_id     = (int) $_GET['ticket_id'];
		$security_code = (string) isset( $_GET['security_code'] ) ? esc_attr( $_GET['security_code'] ) : '';

		// See if the user had access or not to the checkin process
		$checkin_arr = $this->authorized_checkin( $event_id, $ticket_id, $security_code );

		/**
		 * Filters the redirect URL if the user can access the QR checkin
		 *
		 * @param string $url             URL to redirect to, gets escaped upstream
		 * @param int    $event_id        Event Post ID
		 * @param int    $ticket_id       Ticket Post ID
		 * @param bool   $user_had_access Whether or not the logged-in user has permission to perform check ins
		 */
		$url = apply_filters( 'tribe_tickets_plus_qr_handle_redirects', $checkin_arr['url'], $event_id, $ticket_id, $checkin_arr['user_had_access'] );

		wp_redirect( esc_url_raw( $url ) );
		exit;
	}