Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Working example code that shows how to add an answer value from a custom registration form field to Event Espresso's [ESPRESSO_EVENT_ATTENDEES] template.
<?php
/**
* Content Template for the [ESPRESSO_EVENT_ATTENDEES] shortcode
*
* Please be sure to change the Question ID on line 19 to match your custom Question ID
*
* Template Args that are available in this template
* @type EE_Attendee $contact
* @type EE_Event $event
* @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' => 107 // replace with custom question's ID
),
'order_by' => array(
'ANS_ID' => 'DESC'
),
'limit' => 1
),
'ANS_value' );
if( $prev_answer_value ) {
$custom_question_output = ' &mdash; ' . $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 = '';
}
?>
<?php do_action( 'AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar ); ?>
<li><?php echo $gravatar . '&nbsp;' . $contact->full_name() . $custom_question_output; ?></li>
<?php do_action( 'AHEE__content-espresso_event_attendees__after', $contact, $show_gravatar ); ?>
@mafam1024

This comment has been minimized.

Copy link

commented Nov 24, 2017

how can i use this code in my website? did i need to add it to "uploads/espresso/templates" ro edit other files?

@joshfeck

This comment has been minimized.

Copy link
Owner Author

commented Mar 26, 2018

@mafam1024
The recommended approach is you upload the template file into your WordPress child theme's directory.

@BNITampa

This comment has been minimized.

Copy link

commented Aug 9, 2018

SO I used the above code:

get_var( array( array( 'Registration.ATT_ID' => $contact->ID(), 'Registration.EVT_ID' => $event->ID(), 'QST_ID' => 12 // replace with custom question's ID ), 'order_by' => array( 'ANS_ID' => 'DESC' ), 'limit' => 1 ), 'ANS_value' ); if( $prev_answer_value ) { $custom_question_output = ' — ' . $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 = ''; } ?>
  • full_name() . $custom_question_output; ?>
  • --- Is there a way to add a second field (Question ID = 11) and then sort them by the Question ID = 12?

    Question ID 12 is their group name and the leadership of that group needs to know who in their group is registered and working through an entire list of 800+ registrations to find their members would be insane. I need them grouped. THANKS

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    You can’t perform that action at this time.