Support

Home Forums Event Espresso Premium Get ANSWER from Attendees, EEM_Attendee::instance()->get_one

Get ANSWER from Attendees, EEM_Attendee::instance()->get_one

Posted: April 14, 2017 at 11:31 am

Viewing 2 reply threads


RolandK

April 14, 2017 at 11:31 am

Hi EE Support,

I’m trying to make a page for our event manager so in one look there is an overview of our event.

We have 2 kind of tickets available
1. one for Adults
2. one for Children.

Total sum max 8 tickets

An important question in these tickets is: Stays for Diner, Yes or No

I want show in one overview:

1.Total number of attendees ( Knowing that I can see this in the Event) Found this, See code below
2.Total number of Adults ( Knowing that I can see this in the Event
3.Total number of Children ( Knowing that I can see this in the Event
4.Children counted answer: Stays for Diner: Yes
5.Adults counted answer: Stays for Diner: Yes

I know I can use the export functionality and play with that. But for others it seems nice to have a page like this.

I copied some code:

$count_unique_attendee_for_event = EEM_Attendee::instance()->count(
array( array( ‘Registration.EVT_ID’ => EVENT_ID )));
echo ‘Total attendees: ‘ .$count_unique_attendee_for_event.”<br>”;
This works Fine!

I know that when a subscriber has registrated to the event there is a EE_Attendee_ID in the user meta table. So I came up with this code:

$args = array( ‘meta_query’ => array( array( ‘key’ => ‘wp_EE_Attendee_ID’ ), ) );
$EE_Users_ID = get_users( $args );

foreach ( $EE_Users_ID as $users_ee ) {
if ( $users_ee->roles[0] == ‘subscriber’ ) {
if ( $users_ee->wp_EE_Attendee_ID <> ” ) {
echo ‘EE ID found: ‘ . esc_html ($users_ee->kdpow_EE_Attendee_ID) . ‘<br/>’

$reg_id = $users_ee->kdpow_EE_Attendee_ID;
$an_attendee = EEM_Attendee::instance()->get_one( array( array( ‘ATT_ID’ => $reg_id ) ) );

.. till here I don’t know how to read the answers for the different tickets
}
}
}

Can somebody put me in the right direction?

Thanks!
Roland


Josh

  • Support Staff

April 14, 2017 at 11:54 am

Hi Roland,

The way to get the answer will be similar to the code in this gist:

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

There’s a difference though because your loop that loops through Attendees is looping through each primary attendee. So you could add an inner loop that loops through all registrations within the transaction. primar


RolandK

April 14, 2017 at 12:11 pm

Ok Josh, thank you again and I will dive in to that.
Let you know.

Have a good one!
Roland

Viewing 2 reply threads

The support post ‘Get ANSWER from Attendees, EEM_Attendee::instance()->get_one’ 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