• Resolved KramBie

    (@krambie)


    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://ww.wp.xz.cn/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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I just tried your code snippet and it worked perfectly. Here’s what I have in the single event format:

    				{has_attendees}
    <h3>
    SIGNUPS (#_BOOKEDSPACES signups)
    </h3>
    #_ATTENDEESLIST
    {/has_attendees}
    Thread Starter KramBie

    (@krambie)

    I figured it out. I also created its counterpart has_no_attendees, but in that snippet I made a typo:
    if ('has_attendees' == $condition) { without the _no_ which gave weird results. After correcting is worked as to be expected.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Missing conditional place holder for attendees’ is closed to new replies.