Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter themattsearle

    (@themattsearle)

    Many thanks – that’s exactly what I did:

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
        if( !empty($args['scope']) && $args['scope']=='next-seven-days' ){
            $start_date = date('Y-m-d');
            $end_date = date('Y-m-d',strtotime("+7 days"));
            $conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))";
        }
        return $conditions;
    }
    
    add_filter( 'em_get_scopes','my_em_scopes',1,1);
    function my_em_scopes($scopes){
        $my_scopes = array(
            'next-seven-days' => 'Next Seven Days'
        );
        return $scopes + $my_scopes;
    }

    I put that in Snippets and it seems to do exactly what we need.

Viewing 1 replies (of 1 total)