Title: Custom Scope Returns Wrong Set
Last modified: August 21, 2016

---

# Custom Scope Returns Wrong Set

 *  Resolved [onawhim](https://wordpress.org/support/users/onawhim/)
 * (@onawhim)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-scope-returns-wrong-set/)
 * Created a custom scope called Current Events intended to show yesterday and future
   events. The scope shows but it returns all events. I put the code in functions.
   php in the root of TwentyTen, my current theme.
 * add_filter( ’em_events_build_sql_conditions’, ‘current_events_conditions’,1,2);
 * function current_events_conditions($conditions, $args){
    if( !empty($args[‘scope’])&&
   $args[‘scope’]==’current-events’ ){ $yesterday = date(‘Y-m-d’,strtotime(“-1 day”,
   current_time(‘timestamp’))); $conditions[‘scope’] = ” (event_start_date >= CAST(‘
   $yesterday’ AS DATE)”; } return $conditions; } add_filter( ’em_get_scopes’,’current_events_scopes’,
   1,1); function current_events_scopes($scopes){ $my_scopes = array( ‘current-events’
   => ‘Current Events’ ); return $scopes + $my_scopes; }
 * [https://wordpress.org/plugins/events-manager/](https://wordpress.org/plugins/events-manager/)

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

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-scope-returns-wrong-set/#post-4706712)
 * here’s another thread which may help you with this (with sample snippets) –
 * [http://wordpress.org/support/topic/plugin-events-manager-what-other-options-are-there-for-scope-besides-future?replies=5](http://wordpress.org/support/topic/plugin-events-manager-what-other-options-are-there-for-scope-besides-future?replies=5)
   
   [http://wordpress.org/support/topic/plugin-events-manager-show-all-days-of-the-current-week?replies=4](http://wordpress.org/support/topic/plugin-events-manager-show-all-days-of-the-current-week?replies=4)
   [http://wordpress.org/support/topic/events-page-show-todays-upcoming-but-hide-past-event-by-time?replies=5](http://wordpress.org/support/topic/events-page-show-todays-upcoming-but-hide-past-event-by-time?replies=5)
 *  Thread Starter [onawhim](https://wordpress.org/support/users/onawhim/)
 * (@onawhim)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-scope-returns-wrong-set/#post-4706882)
 * angelo,
    Thanks for taking the time to post these links for me. Unfortunately
   they don’t really help as the scope installs but doesn’t calculate. It defaults
   to all events. But this query should work:
 * “event_start_date >= CAST(‘$yesterday’ AS DATE”
    –all dates that are greater 
   than or equal to yesterday where yesterday is…
 * “$yesterday = date(‘Y-m-d’,strtotime(“-1 day”, current_time(‘timestamp’)));”
   —
   one day less than today.
 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-scope-returns-wrong-set/#post-4706893)
 * hmm, you might need a developers assistance to make this work since we can’t 
   help you 100% with regards to custom coding.

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

The topic ‘Custom Scope Returns Wrong Set’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/custom-scope-returns-wrong-set/#post-4706893)
 * Status: resolved