• Resolved jirvin

    (@jrvin)


    Is there a way to hide past events by time, instead of day? For example, I have a list of events for today:

    Event 1, 7:00am to 7:30am
    Event 2, 8:00am to 9:00am
    Event 3, 1:00pm to 3:00pm

    These are not “all day” events. They have specific start/end times. However, all of these events will display until tomorrow. But I’d like for them to stop displaying after the time has passed. For example:

    By 7:31am, I’d like for the 7-7:30 event to not display.
    By 9:01am, I’d like for the 8-9:00am event to not display.
    By 3:01pm, I’d like for the 1-3:00pm event to not display.

    I can’t seem to find a setting/placeholder/hook to handle this. Could anyone give me any tips/point me in the right direction? I feel like it’s right under my nose and I’m missing it.

    Thanks!
    -J

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try this tutorial for custom scope – https://wp-events-plugin.com/tutorials/create-your-own-event-scope/

    Has anyone found a working example for this? I can’t figure out how to make this scope, where to put the code and change it for the time, like the OP asked.

    Thread Starter jirvin

    (@jrvin)

    So this is probably my fault, but I think I asked this right before I updated the plugin (or maybe the update came shortly after my question? I’m not sure?), but things seem to be working how I want them to without creating the custom scope and just using the default “future” for scope.

    That said, I still wanted to try playing with the custom scope thing, so thank you angelo, for providing the tutorial link! I think I could really fine tune with that should the need arise in the future!

    tse11, here’s something I was trying based on the tutorial above. It seemed to work, though I honestly didn’t test much beyond “Yay, I seemed to get the expected results.”
    You’ll probably have to make a few edits to the MySQL bits to fit your needs. You can put it in your theme’s functions.php file:

    //custom scope conditions
    add_filter( ’em_events_build_sql_conditions’, ‘my_em_scope_conditions’,1,2);
    function my_em_scope_conditions($conditions, $args){
    //scope “future-hours”
    if( !empty($args[‘scope’]) && $args[‘scope’]==’future-hours’ ){
    //get the current date
    $start_date = date(‘Y-m-d’,current_time(‘timestamp’));

    //get the current time
    $start_time = date(‘H:i:s’,current_time(‘timestamp’));

    //find all events starting >= to the current date with an end time > than the current time
    $conditions[‘scope’] = ” (event_start_date >= CAST(‘$start_date’ AS DATE) AND event_end_time > CAST(‘$start_time’ AS TIME))”;
    }
    return $conditions;
    }

    //add custom scope “future-hours” to list of available scopes
    add_filter( ’em_get_scopes’,’my_em_scopes’,1,1);
    function my_em_scopes($scopes){
    $my_scopes = array(
    ‘future-hours’ => ‘Future by Hours’
    );
    return $scopes + $my_scopes;
    }

    Jrvin, that is excellent! Thank you so much for taking the time to help and reply. I will try this. I agree, the update does solve some issues but for me not all as far as time. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hide past events by day and time, not just day’ is closed to new replies.