{"id":9346384,"date":"2017-07-24T14:00:48","date_gmt":"2017-07-24T14:00:48","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/custom-scope\/"},"modified":"2017-07-24T14:00:48","modified_gmt":"2017-07-24T14:00:48","slug":"custom-scope","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/custom-scope\/","title":{"rendered":"Custom Scope"},"content":{"rendered":"<p>I have created a custom scope for next 28 days and this works fine. But I would also like to create another scope for the next 56 days and I am unable to create this additional function without receiving 500 internal error, any tips?<\/p>\n<p>This is the existing function<\/p>\n<pre><code>add_filter( &#039;em_events_build_sql_conditions&#039;, &#039;my_em_scope_conditions&#039;,1,2);\nfunction my_em_scope_conditions($conditions, $args){\n\tif( !empty($args[&#039;scope&#039;]) &amp;&amp; $args[&#039;scope&#039;]==&#039;28days&#039; ){\n\t\t$start_date = date(&#039;Y-m-d&#039;,current_time(&#039;timestamp&#039;));\n\t\t$end_date = date(&#039;Y-m-d&#039;,strtotime(&quot;+28 day&quot;, current_time(&#039;timestamp&#039;)));\n\t\t$conditions[&#039;scope&#039;] = &quot; (event_start_date BETWEEN CAST(&#039;$start_date&#039; AS DATE) AND CAST(&#039;$end_date&#039; AS DATE)) OR (event_end_date BETWEEN CAST(&#039;$end_date&#039; AS DATE) AND CAST(&#039;$start_date&#039; AS DATE))&quot;;        \n\t}\n\treturn $conditions;\n    \n}\n\nadd_filter( &#039;em_get_scopes&#039;,&#039;my_em_scopes&#039;,1,1);\nfunction my_em_scopes($scopes){\n\t$my_scopes = array(\n\t\t&#039;28days&#039; =&gt; &#039;Next 28 Days&#039;\n\t);\n\treturn $scopes + $my_scopes;\n}<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-9346384","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9346384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9346384\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9346384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}