• Hello,

    I’ve made a week scope, but it’s not showing the ongoing events.Its filter only by start date.
    My scope:

    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']=='week' ){
    	$current_dayname = date("l");		
            $start_date = date("Y-m-d",strtotime('monday this week'));
            $end_date = date("Y-m-d",strtotime("sunday this week"));
            $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(
            'week' => 'Week'
        );
        return $scopes + $my_scopes;
    }

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Do the missing ongoing events run across several days?

    Thread Starter zotter

    (@zotter)

    Hello,

    yes, for example, for 2 weeks.

    thank you!

    Thread Starter zotter

    (@zotter)

    I’ve tried this code:

    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']=='week' ){
    		
            $start_date = date('Y-m-d',strtotime("-1 year", current_time('timestamp')));
            $end_date = date("Y-m-d",strtotime("sunday this week"));
            $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;
    }

    but it shows events, which finished last week too.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Week scope not showing ongoing events’ is closed to new replies.