Title: Adding a new scope doesn&#8217;t work
Last modified: October 23, 2016

---

# Adding a new scope doesn’t work

 *  Resolved [ituk](https://wordpress.org/support/users/ituk/)
 * (@ituk)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/adding-a-new-scope-doesnt-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)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/adding-a-new-scope-doesnt-work/#post-8346686)
 * can I know what do you mean by “99 years ago” in the code above?
 *  Thread Starter [ituk](https://wordpress.org/support/users/ituk/)
 * (@ituk)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/adding-a-new-scope-doesnt-work/#post-8348059)
 * Thank you for the reply,
    About your question – leave that, the code works in
   the same problematic way even if I change it to “2 years ago” or “3 months ago”
   or whatever. I get the same issue not matter what I change in the `strtotime`
   function.
 * In the bottom line, what I want to create is a scope for all events that ended
   before two months or more.
 * Thanks,
    Itamar
 *  Thread Starter [ituk](https://wordpress.org/support/users/ituk/)
 * (@ituk)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/adding-a-new-scope-doesnt-work/#post-8405906)
 * Angelo?
 *  Thread Starter [ituk](https://wordpress.org/support/users/ituk/)
 * (@ituk)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/adding-a-new-scope-doesnt-work/#post-8506705)
 * ??

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Adding a new scope doesn’t work’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [Old Events](https://wordpress.org/support/topic-tag/old-events/)

 * 4 replies
 * 2 participants
 * Last reply from: [ituk](https://wordpress.org/support/users/ituk/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/adding-a-new-scope-doesnt-work/#post-8506705)
 * Status: resolved