Last active
August 10, 2016 01:47
-
-
Save cliffordp/65ec638e8ef30f28dff8fbfdb7a114f7 to your computer and use it in GitHub Desktop.
Shortcode to display Attendees List for a given Event ID. Example: [tribe_get_event_attendees event_id=11]. Screenshot: https://cl.ly/0L2m140l153A
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 | |
/* | |
* By Nico and Cliff | |
* From https://gist.github.com/cliffordp/65ec638e8ef30f28dff8fbfdb7a114f7 | |
* | |
* Shortcode to display Attendees List for a given Event ID | |
* Example: [tribe_get_event_attendees event_id=11] | |
* Screenshot: https://cl.ly/0L2m140l153A | |
*/ | |
function tribe_get_event_attendees_logic ( $atts ) { | |
if ( ! class_exists( 'Tribe__Tickets__Tickets' ) || ! isset( $atts['event_id'] ) ) { | |
return false; | |
} | |
$defaults = array( | |
'event_id' => 0, | |
); | |
$atts = shortcode_atts( $defaults, $atts, 'tribe_get_event_attendees' ); | |
$event_id = intval( $atts['event_id'] ); | |
if ( empty( $event_id ) ) { | |
return false; | |
} | |
$attendees = Tribe__Tickets__Tickets::get_event_attendees( $event_id ); | |
$output = ''; | |
if( ! empty( $attendees ) ) { | |
$output .= '<h4>Attendees List: ' . get_the_title( $event_id ) . '</h4>'; | |
$output .= '<ul>'; | |
foreach ( $attendees as $attendee ) { | |
$output .= '<li>'. $attendee['purchaser_name'] .' (' . $attendee['purchaser_email'] . ')</li>'; | |
} | |
$output .= '</ul>'; | |
} else { | |
$output .= '<p>There are no attendees for this event yet.</p>'; | |
} | |
return $output; | |
} | |
add_shortcode( 'tribe_get_event_attendees', 'tribe_get_event_attendees_logic' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment