full calendar widget without past events

WordPress Event Management, Calendars & Registration Forums General Question full calendar widget without past events

This topic contains 2 replies, has 2 voices, and was last updated by  Alan Herbert 9 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17367

    I’ve been reading through some of the posts here and wondered if it was now possible to use the full calendar shortcode but exclude past events?

    Also, I’ve now been playing around with Events Organiser Pro and would like to know the best (or correct) way to set up an event that spans several dates i.e 6th, 12th, 17th and 24th for example.

    Currently I have my bookings set to ‘entire series’, created an event with the start and end date on the same day with the timings set and then clicked upon include/exclude occurrences and selected the additional dates. the idea is that all the dates of the event show, but you can only book for all dates and not individual dates. Also, once the event starts, none of the other dates are available.

    I think I have it right but would like to confirm or get the professional guidance.

    I’d also like to demonstrate visually on the calendar that whilst a series of events may be showing , if the event is no longer bookable because the first date in the series has past or the last bookable date has past for example, there is a change to the colouring to an ‘unavailable state’. Are classes applied to facilitate this?

    Many thanks.

    Alan Herbert
    #17370

    Hi Alan,

    This is possible as of 2.13.0, with the following lines of code:

    add_filter( 'eventorganiser_fullcalendar_query', 'my_hide_past_events' );
    function my_hide_past_events( $query ){
        $query['showpastevents'] = false;
        return $query;
    }
    

    That should (ideally) live in a utility plug-in. However, the calendar is cached, so you will probably want to add these lines too:

    add_filter( 'pre_transient_eo_full_calendar_public_priv', '__return_null' );
    add_filter( 'pre_transient_eo_full_calendar_public', '__return_null' );
    

    The set up with regards to events and bookings that you currently have sounds like the correct one for context you describe.

    For styling events which have already started (that is, events in which their first occurrence has started), you can use the following snippet to add any class:

    add_filter( 'eventorganiser_event_classes', 'add_my_event_class', 10, 2 );
    function add_my_event_class( $classes, $event_id ){
         $now = new DateTime( 'now', eo_get_blog_timezone() );
         $schedule_start = eo_get_schedule_start( DATETIMEOBJ )
         if( $schedule_start < $now ){
              $classes[] = 'my-custom-class';
         }
         return $classes;
    }
    

    Alternatively you can also set the events colour directly (it expects a hexadecimal colour value, e.g. #FF0000)

    add_filter( 'eventorganiser_event_color', 'set_event_color', 10, 2 );
    function set_event_color( $color, $event_id ){
             $now = new DateTime( 'now', eo_get_blog_timezone() );
             $schedule_start = eo_get_schedule_start( DATETIMEOBJ )
             if( $schedule_start < $now ){
                   //Change $color;
             }
             return $color;
    }
    
    Stephen Harris
    #17374

    Hi Stephen

    That’s great. I’ll do that tomorrow.

    And a fast response too – Impressed 🙂

    Alan Herbert
Viewing 3 posts - 1 through 3 (of 3 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.