Check if event has passed…

Home Forums Calendar Products Events Calendar PRO Check if event has passed…

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #944193
    Tony
    Participant

    Is there a function to check if the event has passed? I need to check if the event has passed, to be used within the loop in tribe-events/single-event.php.

    #944219
    Gustavo Bordoni
    Keymaster

    Hi Tony,
    Thanks for reaching out to us, and let me try to help you on this request.

    I’ve crafted this snippet with a function to will do that for you, place that on your WordPress Theme’s functions.php file and you will be able to use it on your theme.

    https://gist.github.com/bordoni/63de00ecc10517992053

    My Best Regards,

    #944374
    Tony
    Participant

    Hi Gustavo,

    The use of tribe_get_event() returns a fatal call to undefined function. I believe you want to use tribe_events_get_event() instead. Also the function is comparing the publish date. It should be comparing the event end date. I modified to below, but it’s still not working. I var_dump and $event->end_date returns null even if the event has a specified end date.

    function tribe_is_past_event( $event_id = null ){
    if ( ! tribe_is_event( $event_id ) ){
    return false;
    }
    $event = tribe_events_get_event( $event_id );
    return time() > strtotime( $event->end_date );
    }

    #944376
    Gustavo Bordoni
    Keymaster

    Hi Tony,

    I can only say, I’m truly sorry about that, it was my bad. I just updated the code, it should work as expected now.

    My Best Regards,

    #944388
    Tony
    Participant

    Thanks, works great!

    #944389
    Gustavo Bordoni
    Keymaster

    Perfect, I’m closing this thread and marking the correct answer.

    My Best Regards,

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Check if event has passed…’ is closed to new replies.