Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created December 3, 2016 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/322566085d07254c94b55ed6fcb40c23 to your computer and use it in GitHub Desktop.
Save joshfeck/322566085d07254c94b55ed6fcb40c23 to your computer and use it in GitHub Desktop.
Output a custom registration list on the single event page. Lists the answer to a custom question for each registration.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_details_after_the_content', 'ee_custom_reg_list' ); // use a different hook point to change where this is displayed
function ee_custom_reg_list( $post ){
global $wpdb;
if( is_single() ){ // pass the $post->ID if you want to restrict this to a specific event
$sql = "SELECT ANS_value ";
$sql .= "FROM {$wpdb->prefix}esp_answer ";
$sql .= "INNER JOIN {$wpdb->prefix}esp_registration ";
$sql .= "ON {$wpdb->prefix}esp_answer.REG_ID = {$wpdb->prefix}esp_registration.REG_ID ";
$sql .= "WHERE {$wpdb->prefix}esp_registration.EVT_ID = %d ";
$sql .= "AND {$wpdb->prefix}esp_answer.QST_ID = %d";
$registrations = $wpdb->get_results( $wpdb->prepare( $sql, $post->ID, 12 ) ); // 12 is the Question ID
if ( $registrations ) :
echo '<h4>Attending this event:</h4>';
echo '<ul class="attendee-list">';
foreach( $registrations as $registration ){
$name = $registration->ANS_value;
$html = '<li>'. $name .'</li>';
echo $html;
}
echo '</ul>';
endif;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment