tribe_event_show_tickets( int $post_id = null, object $event = null )

Determine whether to show tickets


Parameters #

$post_id

(int) (Optional) the event ID (optional if used in the loop)

Default value: null

$event

(object) (Optional) The Eventbrite API response for event being checked.

Default value: null


Top ↑

Return #

(bool)


Top ↑

Source #

File: src/functions/template-tags.php

function tribe_event_show_tickets( $post_id = null, $event = null ) {

	$post_id          = Tribe__Events__Main::postIdHelper( $post_id );
	$show_tickets     = get_post_meta( $post_id, '_EventShowTickets', true );
	$should_show_form = tribe_is_truthy( $show_tickets );

	/**
	 * By default, if an event is of the "Canceled", "Completed", "Ended" status, force the ticket form to never show.
	 *
	 * @since 4.4.7
	 *
	 * @param array $statuses The statuses where the event should forcefully have its ticket form hidden.
	 */
	$force_hide_statuses = apply_filters( 'tribe_events_eventbrite_hide_iframe_statuses', array( 'completed', 'ended', 'canceled' ) );

	if (
		! empty( $event ) &&
		! empty( $force_hide_statuses ) &&
		isset( $event->status ) &&
		in_array( $event->status, $force_hide_statuses )
	) {
		$should_show_form = false;
	}

	/**
	 * Let users override the behavior of this template tag and force the form to show.
	 *
	 * @since 1.0
	 *
	 * @param bool $should_show_form Whether to show the form or not. Defaults to yes.
	 */
	return apply_filters( 'tribe_event_show_tickets', $should_show_form );
}

Top ↑

Changelog #

Changelog
Version Description
1.0 Introduced.