Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active February 22, 2018 21:40
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/2cc9773f57abd1bf37cd3bff6ab6c94d to your computer and use it in GitHub Desktop.
Save joshfeck/2cc9773f57abd1bf37cd3bff6ab6c94d to your computer and use it in GitHub Desktop.
<?php
/**
* Content Template for the [ESPRESSO_EVENT_ATTENDEES] shortcode
*
* @package Event Espresso
* @subpackage templates
* @since 4.6.29
* @author Darren Ethier
*
* Template Args that are available in this template
* @type EE_Attendee $contact
* @type bool $show_gravatar whether to show gravatar or not.
*/
$custom_question_output = '';
if( $contact instanceof EE_Attendee ) {
$prev_answer_value = EEM_Answer::instance()->get_var(
array(
array(
'Registration.ATT_ID' => $contact->ID(),
'Registration.EVT_ID' => $event->ID(),
'QST_ID' => 17 // replace with custom question's ID
),
'order_by' => array(
'ANS_ID' => 'DESC'
),
'limit' => 1
),
'ANS_value' );
if( $prev_answer_value ) {
$custom_question_output = '<br><span style="color:#585858; font-style:italic; font-size:.8em;">&nbsp; Player&apos;s Name: &nbsp;</span>' . $prev_answer_value;
}
}
$custom_question_output2 = '';
if( $contact instanceof EE_Attendee ) {
$prev_answer_value = EEM_Answer::instance()->get_var(
array(
array(
'Registration.ATT_ID' => $contact->ID(),
'Registration.EVT_ID' => $event->ID(),
'QST_ID' => 18 // replace with custom question's ID
),
'order_by' => array(
'ANS_ID' => 'DESC'
),
'limit' => 1
),
'ANS_value' );
if( $prev_answer_value ) {
$custom_question_output2 = ' ' . $prev_answer_value;
}
}
if ( $show_gravatar ) {
$gravatar = get_avatar( $contact->email(),
(int) apply_filters( 'FHEE__loop-espresso_attendees-shortcode__template__avatar_size', 32 )
);
} else {
$gravatar = '';
}
$states = EEM_State::instance()->get_all_states();
$state = isset( $states[ $contact->state_ID() ] ) ? $states[ $contact->state_ID() ]->get( 'STA_name' ) : $contact->state_ID();
$state = ! is_numeric( $state ) ? ', ' . $state : '';
$countries = EEM_Country::instance()->get_all_countries();
$country = isset( $countries[ $contact->country_ID() ] ) ? $countries[ $contact->country_ID() ]->get( 'CNT_name' ) : $contact->country_ID();
$country = ! empty( $country ) ? ', ' . $country : '';
$group_size = $contact->get_most_recent_registration_for_event( $event->get('EVT_ID'))->get('REG_group_size');
// if group size is 1, ditch the quantity display
$group_size = $group_size > 1 ? '<br><span style="color:#C0C0C0; font-style:italic; font-size:.8em;">&nbsp; Total entries by Registrant (if >1): (' . $group_size . ')</span>' : '';
do_action( 'AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar );
$registrations = array();
if ($contact instanceof EE_Attendee) {
$registrations = EEM_Registration::instance()->get_all(array(
array(
'ATT_ID' => $contact->ID(),
'EVT_ID' => $event->ID()
),
));
}
foreach($registrations as $registration ){
if($registration instanceof EE_Registration){
echo '<li>' . $gravatar . '&nbsp;' . $contact->full_name() . ' '
. ' &ndash; '
. '<span style="color:#C0C0C0;">'
. $contact->city()
. $state
. '</span>'
. $group_size
. '<span style="color:#707070; font-style:italic;">'
. $custom_question_output
. $custom_question_output2
. '</span></li>';
}
}
do_action( 'AHEE__content-espresso_event_attendees__after', $contact, $show_gravatar );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment