AyeCode / events-for-geodirectory

The Events Calendar for GeoDirectory allows you to create a Directory of GeoEvents. Recurring Events, Events Locator with maps, the Events Calendar widget, sorting events by upcoming are the main features of this add-on for GeoDirectory.
https://wpgeodirectory.com/downloads/events/
Other
2 stars 2 forks source link

Feedback - make 'upcoming' not include 'ongoing' #175

Closed alexrollin closed 2 years ago

alexrollin commented 2 years ago

Member wants to remove/filter out events that didn't start on "Today" or "Day/Time X"

Upcoming would be events on that and and after but nothing that started before that day/time.

Ongoing is for events that started on or before the day as well as upcoming.

https://secure.helpscout.net/conversation/1732855500/27638/

kprajapatii commented 2 years ago

This can be achieved by PHP snippet.

/**
 * Hide ongoing events from upcoming & ongoing events list.
 */
function gd_snippet_filter_event_types( $filters, $event_type, $alias, $date ) {
    $now = $date . ' ' . date_i18n( 'H:i:s' );

    $filters['upcoming'] = "CONCAT( {$alias}start_date, ' ', {$alias}start_time ) > '{$now}' ";
    $filters['ongoing'] = "( CONCAT( {$alias}start_date, ' ', {$alias}start_time ) <= '{$now}' ) AND ( CONCAT( {$alias}end_date, ' ', {$alias}end_time ) > '{$now}' OR CONCAT( {$alias}end_date, ' ', {$alias}end_time ) = '{$date} 00:00:00' ) ";

    return $filters;
}
add_filter( 'geodir_event_type_query_filters', 'gd_snippet_filter_event_types', 10, 4 );

function gd_snippet_add_event_type( $options, $post_type ) {
    $options['ongoing'] = __( 'Ongoing', 'geodirevents' );

    return $options;
}
add_filter( 'geodir_event_filter_options', 'gd_snippet_add_event_type', 10, 4 );