Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Registers a [public_attendee_list] shortcode. Should work with The Events Calendar + WooCommerce Tickets (or any of the other related ticketing addons). Simply drop the shortcode into the event description and it will *publicly* list how many folks are attending etc... tweak to make it fit your own needs! You may for instance wish to add a check…
<?php
/**
* Generates output for the [public_attendee_list] shortcode.
*
* Assumes we're interested in the current event or, optionally, a specific
* event ID can be provided:
*
* [public_attendee_list id="789"]
*
* This is a rudimentary starting point only! Please assess and tweak to
* fit your own needs.
*
* @param $params
* @return string
*/
function build_public_attendee_list( $params ) {
// Which event are we interested in?
if ( is_array( $params ) && isset( $params['id'] ) ) $id = absint( $params['id'] );
else $id = get_the_ID();
// Is it truly an event?
if ( TribeEvents::POSTTYPE !== get_post_type( $id ) )
return '<p> Unable to display attendee list: this does not seem to be a valid event. </p>';
// Get the attendees
$attendees = TribeEventsTickets::get_event_attendees( $id );
// Perhaps no one is attending
if ( empty( $attendees ) )
return '<p> No confirmed attendees just yet. </p>';
// Form a report of any known attendees
$report = '<p>' . count( $attendees ) . ' confirmed attendees: </p> <ul>';
foreach ( $attendees as $attending ) {
$name = esc_html( $attending['purchaser_name'] );
$order = esc_html( $attending['order_id'] );
$report .= "<li> $name (#$order) </li>";
}
return $report . '</ul>';
}
// Register our new [public_attendee_list] shortcode
add_shortcode( 'public_attendee_list', 'build_public_attendee_list' );
@barryhughes

This comment has been minimized.

Copy link
Owner Author

@barryhughes barryhughes commented Nov 26, 2014

Quick use: add to your theme's functions.php file (but remember that, typically, you will need to remove the leading <?php tag before doing this).

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.