Support

Home Forums Community Forum Show number of people registered on an event – specific status

Show number of people registered on an event – specific status

Posted: January 28, 2022 at 5:56 am


ridos

January 28, 2022 at 5:56 am

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

It helped me a lot but it shows only total registrations including incomplete ones and registrations from trash…

Will someone be able to modify this code to show number of registrations for specific event witch specific status of registration? By expample RAP Status.


ridos

January 31, 2022 at 3:20 am

Done I added condition to SQL query. For anyone else it should be then.

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’ AND STS_ID = ‘enter_registration_status'”);
return ‘Razem: ‘. $count . ‘ Potwierdzonych Uczestników’;
}


Tony

  • Support Staff

January 31, 2022 at 7:17 am

Hi there,

When working with Event Espresso we have a model system to make doing this much easier (obviously once you know how the models work that is).

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

I know you didn’t write that code, but using the models the above becomes:


add_shortcode('EVENT_ATTENDEE_NUMBER','fun_display_attendee_number');
function fun_display_attendee_number($atts)
{
    if(! class_exists('EEM_Registration') ) {
	return;
    }

    $where_params = array(
	'EVT_ID' => $atts['event_id'],
	'STS_ID' => 'RAP'
    );

    $count = EEM_Registration::instance()->count(array($where_params));
    return 'Razem: '. $count . ' Potwierdzonych Uczestników';
}

Event Espresso handles everything else for you, you just need to learn what you can pass to the models, and how to pass it, to easily pull various details.

You could easily customize the above to be able to pass the specific registration status for the shortcode instance into the attributes etc but the idea being, if you want data from Event Espresso, use the models to make you life easier.


ridos

January 31, 2022 at 10:34 am

THANK YOU VERY MUCH TONY!!! YOU ARE THE BEST 🙂

The support post ‘Show number of people registered on an event – specific status’ 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