Last active
November 3, 2021 13:07
-
-
Save cliffordp/68e3fde2c05efc61b9df9688a3fb5d53 to your computer and use it in GitHub Desktop.
Template override for [tribe-user-event-confirmations] to add PDF Ticket links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
@vlinas This template is getting updated within the next week or two (as you can see here: https://github.com/moderntribe/event-tickets/blob/release/G20.06/src/views/shortcodes/my-attendance-list.php) so that change might be what you want anyway. If not, I'd try again from there. I haven't tested this snippet since creating it. Let me know if you find it needs a refresh from this template update or from the latest version of PDF Tickets (https://github.com/mt-support/tribe-ext-pdf-tickets)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @cliffordp , thanks for this snippet. I just tried it with the latest version of event tickets plus plugin, however it doesn't work for me. The events list doesn't get updated with pdf links, which I was looking to implement on my page.
I am aware that PDF Tickets extension is required, but is there anything else that I'm missing? Thanks!