Last active
December 3, 2020 17:41
-
-
Save joshfeck/63fe625950c9a71e19be to your computer and use it in GitHub Desktop.
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.
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
<?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 = ' — ' . $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 . ' ' . $contact->full_name() . $custom_question_output; ?></li> | |
<?php do_action( 'AHEE__content-espresso_event_attendees__after', $contact, $show_gravatar ); ?> |
@mafam1024
The recommended approach is you upload the template file into your WordPress child theme's directory.
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 = ''; } ?>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
how can i use this code in my website? did i need to add it to "uploads/espresso/templates" ro edit other files?