Custom Event Scopes Not Working with Other Arguments
-
Hi there!
I built a custom event scope using the instructions on this page:
https://wp-events-plugin.com/tutorials/create-your-own-event-scope/
But I noticed that when I called EM_Event::get() with this custom scope along with other parameters (category, town, etc.), the other parameters would be ignored, and all events within the custom scope would be displayed.
I did some digging around in the code, and figured out what was going wrong. When hooking into the scope, rather than passing this:
$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))”;
the custom scope function should pass this:
$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)) )”;
Just wanted to pass this along in case anyone else is having this problem, or if the plugin developers wanted to update the tutorial page on their site. (You do great work BTW developers, both on the plugin itself and engaging with forum users. Thanks!)
- The topic ‘Custom Event Scopes Not Working with Other Arguments’ is closed to new replies.