Created
December 3, 2016 02:15
-
-
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.
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 | |
//* 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