Support

Home Forums Event Espresso Premium How to show the total number of attendees for an event

How to show the total number of attendees for an event

Posted: March 2, 2021 at 9:16 pm

Viewing 5 reply threads


monteail

March 2, 2021 at 9:16 pm

My EE4 works great. I now want to show the total number of attendees per event. I can see them in the WordPress Dashboard but how do I display them in a post?


monteail

March 3, 2021 at 9:23 am

I only want the approved registrations.

I tried the code I found and this does not return the correct number:

add_shortcode(‘EVENT_ATTENDEE_NUMBER’,’fun_display_attendee_number’);
function fun_display_attendee_number($atts)
{
global $wpdb;
$event_id = $atts[‘event_id’];
$registration_table = $wpdb->prefix.’esp_registration’;
$count = $wpdb->get_var(“SELECT COUNT(REG_ID) FROM $registration_table WHERE EVT_ID=’$event_id'”);
return ‘Number of registrations: ‘. $count;
}


monteail

March 3, 2021 at 9:44 am

I then used the shortcode: [EVENT_ATTENDEE_NUMBER event_id=2723] That event has a different number than the actual registered attendees…


Tony

  • Support Staff

March 4, 2021 at 9:13 am

Hi there,

Just to note, if you are using code from the forums, it’s best to include a link to the forum post so we have some additional context on that code. So it looks like it’s the code shared by WisdmLabs here:

https://eventespresso.com/topic/show-number-of-people-registered-on-an-events-page/#post-175221

Which doesn’t include any specific registration status so would include ALL registrations on that event.

The problem with what you are looking to do is people set up the events in different ways which then changes how the values need to be pulled in.

Here is an example that pulls in all registrations across the tickets assigned to the ‘next’ upcoming datetime for an event:

https://gist.github.com/Pebblo/f89e3a7076acde7e7998

Is that what you are looking for?


monteail

March 4, 2021 at 12:14 pm

All I want is for this to count the number of approved attendees. Similar to the shortcode [ESPRESSO_EVENT_ATTENDEES event_id=3510] except it provides a count of the attendees instead of listing their names.


Tony

  • Support Staff

March 4, 2021 at 1:27 pm

[ESPRESSO_EVENT_ATTENDEES]

Uses EE_Contacts linked to the registration on an event. For example, if you have 10 registrations all linked to the contact (same First Name, Last Name & Email Address), the above shortcode would should 1 attendee.

How many datetimes in your event?

How many tickets on those datetimes?

Viewing 5 reply threads

The support post ‘How to show the total number of attendees for an event’ 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