Missing conditional place holder for attendees

[ad_1]

I am looking for conditional placeholder has_attendees, but surprisingly there seems not to be such a placeholder.

So I tried to make my own condtional placeholder based on the suggestion done here: https://projectdmc.org/support/topic/field-for-organizer. Unfortunate my code isn’t working. No matter the event has attendees or not the outcome is always true. This is my code:

add_filter('em_event_output_show_condition', 'my_em_has_attendees', 1, 4);
/* Whether to display the event format content between {has_attendees}the content{/has_attendees} */
function my_em_has_attendees($show, $condition, $full_match, $EM_Event)
{
    if ('has_attendees' == $condition) {
        $EM_Bookings = $EM_Event->get_bookings();
        $EM_MyCountBookings = 0;
        foreach ($EM_Bookings as $EM_Booking) {
            if ($EM_Booking->booking_status == 1) {
                $EM_MyCountBookings += 1;
            }
        }
        if ($EM_MyCountBookings > 0) {
            $show = true;
        }
    }
    return $show;
}

What did I do wrong?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer