• Resolved fersamp

    (@fersamp)


    Hi everyone,

    I tried to use filter today-tomorrow but it doesn’t work even if I use it directly 🙁 …
    I would like to start from that filter to implement a filter by a single date passed from datepicker, more complex…why this is not working? This should filter for today ( even is just implemented from authors, I would like to understand how to use the filter manually )

    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']=='my_custom_date' ){
    		$start_date = date('Y-m-d', current_time('timestamp'));
    		$end_date = date('Y-m-d', 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(
    		'my_custom_date' => 'My custom date'
    	);
    	return $scopes + $my_scopes;
    }

    https://wordpress.org/plugins/events-manager/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    hi,

    is the above is your actual custom scope? also, did you used it in a shortcode or somewhere else?

    thanks

    Thread Starter fersamp

    (@fersamp)

    I only paste this in my functions.php. The scope appears in backend but it seems not working…How can I filter only by one single date? How is it the correct steps to implement filters? I read the tutorial but I didn’t understand which files I have to change

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

The topic ‘Filter Events List problem’ is closed to new replies.