Adding a new scope doesn’t work
-
Hey,
I’m trying to add a new scope to present events that were ended two months ago or before. I’ve copied the functions for adding custom scopes from the plugins documentation, edited them a bit, but it just won’t work. I always get the same result when I filter to this scope on the admin side: a list of something like 90% of the events (I have no idea why only 90%), including events from the last two month and future events as well. I have no idea why it’s like that…Here is my 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']=='two-months-ago' ){ $start_date = date('Y-m-d',strtotime("99 years ago", current_time('timestamp'))); $end_date = date('Y-m-d',strtotime("2 months ago", current_time('timestamp'))); $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( 'two-months-ago' => 'Two Months Ago' ); return $scopes + $my_scopes; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Adding a new scope doesn’t work’ is closed to new replies.