Skip to content

Instantly share code, notes, and snippets.

@Apina
Last active August 29, 2015 14:06
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 Apina/a7bd83cdb4e2fa9788dd to your computer and use it in GitHub Desktop.
Save Apina/a7bd83cdb4e2fa9788dd to your computer and use it in GitHub Desktop.
EE4 List attendees shortcode (basic)
//shortcocde is: [ee_attendee_list event_id=""]
//This would be added to either the themes functions.php or a custom functions plugin
add_shortcode( 'ee_attendee_list', 'ee_attendee_list' );
function ee_attendee_list($atts){
$post_id = $atts['event_id'];
global $wpdb, $post;
if(is_singular()){
echo '<ul class="attendee-list">';
$sql = "SELECT ATT_fname, ATT_lname, ATT_email ";
$sql .= "FROM {$wpdb->prefix}esp_attendee_meta ";
$sql .= "INNER JOIN {$wpdb->prefix}esp_registration ";
$sql .= "ON {$wpdb->prefix}esp_attendee_meta.ATT_ID = {$wpdb->prefix}esp_registration.ATT_ID ";
$sql .= "WHERE {$wpdb->prefix}esp_registration.EVT_ID = %d";
$attendees = $wpdb->get_results( $wpdb->prepare( $sql, $post_id ));
foreach($attendees as $attendee){
$fname = $attendee->ATT_fname;
$lname = $attendee->ATT_lname;
$email = $attendee->ATT_email;
$gravatar = get_avatar( $email, '64', 'identicon' );
$html = '<li>'. $gravatar .'<span>'. $fname .' '. $lname . '</span></li>';
echo $html;
}
echo '</ul>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment