Can I disable the End Time feature

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6151

    Hi Stephen,
    I’m currently setting up EO for a bar to list the bands that play there. The music starts at 9:30pm and ends at 2am. If I list the end time as 2am on the next day, the event is listed on the calendar as starting on the second day. I don’t want that to happen, and I would be fine with not listing an end time at all. Is that possible? And, if it is possible, can some events include end times, and some not?
    Thanks,
    Nick

    nickverde
    #6153

    Hi Nick,

    Events must have an end time unfortunately. But you can suppress this, for instance, using custom fields. E.g. create a custom field with key suppress_end_time and value 1, and in the templates wherever you want to suppress the end time:

    if( get_post_meta( $post_id, 'suppress_end_time', true ) ){
        //Do not display end time
    }else{
        //Display end time
    }
    

    (assuming that for some events you will want to display when it finishes).

    The calendar is a bit subtler – you can use this filter: eventorganiser_fullcalendar_event – which filters an event array before its added to the calendar. For events you wish to suppress the end-time, simply change the ‘end’ key to midnight that day:

    (Completely untested…)

    add_filter( 'eventorganiser_fullcalendar_event', 'my_custom_callback', 10, 3 );
    function my_custom_callback( $event, $post_id, $occurrence_id ){
        if( get_post_meta( $post_id, 'suppress_end_time', true ) ){
            //Suppressing end-time, set it to just before midnight of the start date
            $end = eo_get_the_start( DATETIMEOBJ, post_id, $occurrence_id );
            $end->setTime( 23, 59, 59 ); //Set to just before midnight
            $event['end'] = $end->format('Y-m-d\TH:i:s\Z');
        }
        return $event;
    }
    

    Note: The calendar is cached, so the filter’s change won’t take immediate effect. To clear the cache simply ‘update’ an event.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.