Better Display of RSVP counts in Events+

An issue we noticed in Events+ is that the total RSVP count is only displayed in one place, which is in the dashboard on the all events page. They are not displayed on the front end, nor on the event edit page. The impact of it is even worse for recurring events since the RSVP count isn't displayed anywhere (being that only the root event is displayed on the all events list in the dashboard. The recurring "virtual" ones are not).

It would be useful to (at least have the option) display the RSVP counts next to the words "Attending", "Maybe", and "No" on the front end and in the RSVP section of the dashboard edit page. This should also apply to the RSVP widget as well as that is a good option for displaying the RSVPs (it would probably even be easiest to add it as an option to the widget).

  • Vaughan
    • Support/SLS MockingJay

    Hi @Saunt Valerian,

    That would make a nice addition, I can certainly add this to the features list for the developer to look at in a future release.

    Let me just ask one of our devs if there's a quick solution for this at all, but if not, it would have to be added as a future feature.

    Hope this helps

  • Jose
    • Bruno Diaz

    Hey there @Saunt Valerian,

    Hope you are doing great :slight_smile:

    I accepted the challenge and just developed this small must-use plugin for you.
    To install it, just drop the attached PHP file into the folder ../wp-content/mu-plugins/ (create the folder if it doesn't exists).

    It will hook into the filters 'eab-rsvps-button' and add the attendees count number to the buttons label for the single event view. (see attached image).

    But that is not all, the plugin also provides a handy static method that you can invoke from any place in your code.
    For instance, if you want to show the attendees count in the event list view, you just need to modify the template and add something like this to get the magic number:
    Events_Attendees_Count::get_event_attendees($event_id = false, $post = false, $status = false);

    You can use alternatively the event_id or the post object as parameter, setting the other to false. The third parameter is the status, which can be any of the following defined constants:


    So, a working example would look like this:

    global $post;
    $yes_count = Events_Attendees_Count::get_event_attendees(false, $post, Eab_EventModel::BOOKING_YES);
    echo $yes_count; //this should print the confirmed attendees count.

    Please give it a try and let me know how it works.


    Just for reference, this is the plugin code:

    if(! class_exists('Events_Attendees_Count') ):
        class Events_Attendees_Count{
            function __construct(){
                add_filter('eab-rsvps-button-yes', array($this, 'add_button_count_yes'), 20, 2);
                add_filter('eab-rsvps-button-maybe', array($this, 'add_button_count_maybe'), 20, 2);
                add_filter('eab-rsvps-button-no', array($this, 'add_button_count_no'), 20, 2);
            public function add_button_count_yes($markup, $event_id) {
                $count = self::get_event_attendees($event_id, false, Eab_EventModel::BOOKING_YES);
                $partial = substr($markup,0,strpos($markup,'value=')+7);
                $new_markup = $partial . __('I\'m attending', Eab_EventsHub::TEXT_DOMAIN) .
                        '(' . $count . ')' .
                        '" />';
                return $new_markup;
            public function add_button_count_maybe($markup, $event_id) {
                $count = self::get_event_attendees($event_id, false, Eab_EventModel::BOOKING_MAYBE);
                $partial = substr($markup,0,strpos($markup,'value=')+7);
                $new_markup = $partial . __('Maybe', Eab_EventsHub::TEXT_DOMAIN) .
                    '(' . $count . ')' .
                    '" />';
                return $new_markup;
            public function add_button_count_no($markup, $event_id) {
                $count = self::get_event_attendees($event_id, false, Eab_EventModel::BOOKING_NO);
                $partial = substr($markup,0,strpos($markup,'value=')+7);
                $new_markup = $partial . __('No', Eab_EventsHub::TEXT_DOMAIN) .
                    '(' . $count . ')' .
                    '" />';
                return $new_markup;
            public static function get_event_attendees($event_id = false, $post = false, $status = false){
                global $wpdb;
                $count = -1;
                    if(!$post)return $count;
                    $event = ($post instanceof Eab_EventModel) ? $post : new Eab_EventModel($post);
                    $event_id = $event->get_id();
                    case Eab_EventModel::BOOKING_YES:
                        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".Eab_EventsHub::tablename(Eab_EventsHub::BOOKING_TABLE)." WHERE event_id = %d AND status = %s;", $event_id, Eab_EventModel::BOOKING_YES));
                    case Eab_EventModel::BOOKING_MAYBE:
                        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".Eab_EventsHub::tablename(Eab_EventsHub::BOOKING_TABLE)." WHERE event_id = %d AND status = %s;", $event_id, Eab_EventModel::BOOKING_MAYBE));
                    case Eab_EventModel::BOOKING_NO:
                        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".Eab_EventsHub::tablename(Eab_EventsHub::BOOKING_TABLE)." WHERE event_id = %d AND status = %s;", $event_id, Eab_EventModel::BOOKING_NO));
                return $count;
        new Events_Attendees_Count;

  • Saunt Valerian
    • The Bug Hunter

    Nicely done, Jose! While I probably won't be using the template mods the count in the button is a very nice touch and good implementation. You might consider submitting this to be added into Events+ core as an Add-on to be activated.

    This is nice. Screenshot in action. The only change I made to it was to add a space on lines 15, 26, and 36 (where the paranthesis and count were setup to display) so that the numbers weren't crowding the words on the button.

    Thank you for doing this!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.