-
-
Save Apina/a7bd83cdb4e2fa9788dd to your computer and use it in GitHub Desktop.
EE4 List attendees shortcode (basic)
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
//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