Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Created January 24, 2014 04:46
Show Gist options
  • Save sidharrell/8592212 to your computer and use it in GitHub Desktop.
Save sidharrell/8592212 to your computer and use it in GitHub Desktop.
cool sortable attendee list
<?php
// add as uploads/espresso/templates/attendee_list.php
// note the enqueue script on line 47. You'll need to upload sortable.min.js and adjust the location
// also it has been customized for questions #39 and 40. YMMV.
//List Attendees Template
//Show a list of attendees using a shortcode
//[LISTATTENDEES]
//[LISTATTENDEES limit="30"]
//[LISTATTENDEES show_expired="false"]
//[LISTATTENDEES show_deleted="false"]
//[LISTATTENDEES show_secondary="false"]
//[LISTATTENDEES show_gravatar="true"]
//[LISTATTENDEES paid_only="true"]
//[LISTATTENDEES show_recurrence="false"]
//[LISTATTENDEES event_identifier="your_event_identifier"]
//[LISTATTENDEES category_identifier="your_category_identifier"]
//Please refer to this page for an updated lsit of shortcodes: http://eventespresso.com/forums/?p=592
/*Example CSS for your themes style sheet:
li.attendee_details{
display:block;
margin-bottom:20px;
background: #ECECEC;
border:#CCC 1px solid;
}
.espresso_attendee{
width:400px;
padding:5px;
}
.espresso_attendee img.avatar{
float:left;
padding:5px;
}
.clear{
clear:both;
}
*/
//The following code displays your list of attendees.
//The processing for this function is managed in the shortcodes.php file.
if (!function_exists('event_espresso_show_attendess')) {
function event_espresso_show_attendess($sql,$show_gravatar,$paid_only, $sort=''){
//echo $sql;
global $wpdb,$this_is_a_reg_page;
wp_enqueue_script( 'sortablescript', EVENT_ESPRESSO_PLUGINFULLURL . 'scripts/sorttable.min.js' );
$events = $wpdb->get_results($sql);
foreach ($events as $event){
$event_id = $event->id;
$event_name = stripslashes_deep($event->event_name);
/*if (!$this_is_a_reg_page){
$event_desc = do_shortcode(stripslashes_deep($event->event_desc));
}*/
//This variable is only available using the espresso_event_status function which is loacted in the Custom Files Addon (http://eventespresso.com/download/plugins-and-addons/custom-files-addon/)
//$event_status = function_exists('espresso_event_status') ? ' - ' . espresso_event_status($event_id) : '';
//Example usage in the event title:
/*<h2><?php _e('Attendee Listing For: ','event_espresso'); ?><?php echo $event_name . ' - ' . $event_status?> </h2>*/
?>
<table id="" class="sortable">
<thead>
<tr class="row1">
<th class="col1 sorttable_alpha"></th>
<th class="col2 sorttable_alpha">Last Name</th>
<th class="col3 sorttable_alpha">First Name</th>
<th class="col4 sorttable_alpha">City</th>
<th class="col5 sorttable_alpha">NITK Batch (Year of graduation)</th>
<th class="col6 sorttable_alpha">Degree(s)</th>
</tr>
</thead>
<tbody>
<?php
$a_sql = "SELECT a.*, asw39.answer answer39, asw40.answer answer40 FROM " . EVENTS_ATTENDEE_TABLE . " a ";
$a_sql .= "LEFT JOIN " . EVENTS_ANSWER_TABLE . " asw39 ON asw39.question_id=39 AND asw39.attendee_id=a.id ";
$a_sql .= "LEFT JOIN " . EVENTS_ANSWER_TABLE . " asw40 ON asw40.question_id=40 AND asw40.attendee_id=a.id ";
$a_sql .= "WHERE a.event_id='" . $event_id . "'";
$a_sql .= $paid_only == 'true'? " AND (payment_status='Completed' OR payment_status='Pending' OR payment_status='Refund') ":'';
$a_sql .= $sort;
//echo $a_sql;
$attendees = $wpdb->get_results($a_sql);
$index = 1;
foreach ($attendees as $attendee){
$index++;
$id = $attendee->id;
$lname = $attendee->lname;
$fname = $attendee->fname;
$city = $attendee->city;
$state = $attendee->state;
$country = $attendee->state;
$email = $attendee->email;
$gravatar = $show_gravatar == 'true'? get_avatar( $email, $size = '100', $default = 'http://www.gravatar.com/avatar/' ) : '';
$city_state = $city != '' || $state != '' ? '<br />' . ($city != '' ? $city :'') . ($state != '' ? ', ' . $state :' ') :'';
//These are example variables to show answers to questions
//$custom_question_1 = '<br />'.do_shortcode('[EE_ANSWER q="12" a="'.$id.'"]');
//$custom_question_2 = '<br />'.do_shortcode('[EE_ANSWER q="13" a="'.$id.'"]');
?>
<tr class="row<?php echo $index; ?>">
<td class="col1 sorttable_alpha"><?php echo $index-1; ?></td>
<td class="col2 sorttable_alpha"><?php echo $lname; ?></td>
<td class="col3 sorttable_alpha"><?php echo $fname; ?></td>
<td class="col4 sorttable_alpha"><?php echo $city; ?></td>
<td class="col5 sorttable_alpha"><?php echo $attendee->answer39; ?></td>
<td class="col6 sorttable_alpha"><?php echo $attendee->answer40; ?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot></tfoot>
</table>
<?php
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment