Advertisement
eventsmanager

Custom Scope: Today and Future Events

Jul 12th, 2023 (edited)
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /*
  2. Usage: [events_list scope="today-future"]
  3. */
  4.  
  5. add_filter( 'em_get_scopes','my_em_today_scopes',1,1);
  6. function my_em_today_scopes($scopes){
  7. $my_scopes = array(
  8. 'today-future' => 'Today and Future'
  9. );
  10. return $scopes + $my_scopes;
  11. }
  12.  
  13. add_filter( 'em_events_build_sql_conditions', 'my_em_today_scope_conditions',100,2);
  14. function my_em_today_scope_conditions($conditions, $args){
  15. if( !empty($args['scope']) && $args['scope']=='today-future' ){
  16. $date_today = date('Y-m-d',current_time('timestamp'));
  17. $conditions['scope'] = " (event_start_date >= CAST('".$date_today."' AS DATE) OR event_end_date >= CAST('".$date_today."' AS DATE))";
  18. }
  19. return $conditions;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement