Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Template override for [tribe-user-event-confirmations] to add PDF Ticket links
<?php
/**
* Renders the My Attendance list
*
* Override this template in your own theme by creating a file at:
*
* [your-theme]/tribe-events/tickets/shortcodes/my-attendance-list.php
*
* @version 4.3.5
*
* @var array $event_ids
*/
?>
<ul class="tribe-tickets my-attendance-list">
<?php foreach ( $event_ids as $id ): ?>
<?php $start_date = tribe_get_start_date( $id ); ?>
<li class="event-<?php echo esc_attr( $id ) ?>">
<a href="<?php echo esc_url( get_permalink( $id ) ); ?>" target="_blank">
<?php echo get_the_title( $id ); ?>
<?php if ( $start_date ): ?>
<span class="datetime">(<?php echo $start_date; ?>)</span>
<?php endif; ?>
</a>
<!-- Implement PDF Ticket per event -->
<?php
/**
* @link https://gist.github.com/cliffordp/68e3fde2c05efc61b9df9688a3fb5d53 Snippet of this entire file.
* @link https://cl.ly/271Q3K072a1u Screenshot of how it works for me (and hopefully for you, too).
* @link https://github.com/moderntribe/event-tickets/blob/4.7.6/src/views/shortcodes/my-attendance-list.php The original version of this file, for historical reference.
*/
if ( method_exists( 'Tribe__Extension__PDF_Tickets', 'ticket_link' ) ) {
$all_attendees = Tribe__Tickets__Tickets::get_event_attendees( $id );
$user_attendees = [];
$current_user = get_current_user_id();
foreach ( $all_attendees as $attendee ) {
if ( $current_user !== absint( $attendee['user_id'] ) ) {
$user_attendees[] = $attendee;
}
}
if ( ! empty( $user_attendees ) ) {
echo '<ul class="users-tickets-per-event">';
foreach ( $user_attendees as $user_attendee ) {
printf( '<li>Attendee #%d: %s</li>',
$user_attendee['attendee_id'],
Tribe__Extension__PDF_Tickets::instance()->ticket_link( $user_attendee['attendee_id'] )
);
}
echo '</ul>';
}
}
?>
<!-- End PDF Tickets customization -->
</li>
<?php endforeach; ?>
<?php if ( empty( $event_ids ) ): ?>
<li class="event-none">
<?php esc_html_e( 'You have not indicated your attendance for any upcoming events.', 'event-tickets' ); ?>
</li>
<?php endif; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.