custom event scope behaving strangely!
-
Hi
I’ve been looking at this tutorial
https://wp-events-plugin.com/tutorials/create-your-own-event-scope/And reused the code here:
https://www.ads-software.com/support/topic/plugin-events-manager-what-other-options-are-there-for-scope-besides-future?replies=5I can’t notice anything wrong with the code, but I am getting events dating way back being pulled in!
See here, the event in India is a good example of one that shouldn’t be there:
https://carshow.life/map-scope-test-page/Scope is set to ‘nextfornight’ with this code in my functions.php file:
/* Custom events 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’]==’nextfortnight’ ){
$start_date = date(‘Y-m-d’,current_time(‘timestamp’));
$end_date = date(‘Y-m-d’,strtotime(“+14 days”, 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(
‘nextfortnight’ => ‘Next Fortnight’
);
return $scopes + $my_scopes;
}Whats going wrong?!
Thanks!
- The topic ‘custom event scope behaving strangely!’ is closed to new replies.