Support

Home Forums Event Espresso Premium List Attendees with 'City' and 'State' System Question Data

List Attendees with 'City' and 'State' System Question Data

Posted: March 17, 2016 at 6:50 am

Viewing 3 reply threads


Jeffrey Carter

March 17, 2016 at 6:50 am

The instructions about editing the espresso_event_attendees.php template are great.

https://eventespresso.com/wiki/ee4-shortcodes-template-variables/

And the code to append question data according to a question’s QST_ID number also works well when the question is a custom question.

https://gist.github.com/joshfeck/63fe625950c9a71e19be

However, I can’t get a system question’s answer data to work. For example if I want “City” (ID=6), using that ID on line 19 in the code yields no results.

<?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
				),

I’m trying to modify the espresso_event_attendees.php template to display the attendee’s name, city and state… e.g.,

• John Smith — Atlanta, GA

But I hit this snag. I will be very grateful for any advice about how to modify this EE4 template to list attendees this way.

Thanks,

Jeff


Josh

  • Support Staff

March 17, 2016 at 5:19 pm

You can use the city() method and echo it out, eg:

<?php echo $contact->city(); ?>


Jeffrey Carter

March 18, 2016 at 6:35 am

Ah, yes! That’s the ticket. To get my desired output of:

• John Smith — Atlanta, GA

I ended up with this for line 40 in espresso_event_attendees.php as modified according to:

https://gist.github.com/joshfeck/63fe625950c9a71e19be

<li><?php echo $gravatar . '&nbsp;' . $contact->full_name() . $custom_question_output . '&nbsp; &mdash; &nbsp;' . $contact->city() . ', &nbsp;' . $contact->state(); ?></li>

Works great. Thanks for the tip!


Tony

  • Support Staff

March 18, 2016 at 7:17 am

Hi Jeff,

Thanks for sharing your solution 🙂

If you have any further questions just let us know.

Viewing 3 reply threads

The support post ‘List Attendees with 'City' and 'State' System Question Data’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso