• Resolved Extrafino

    (@extrafino)


    I have been using this code for some time to remove events after one hour from the widget. It hast somehow stopped working and events will not simply show until the next day.

    // Future and X hours ago aka 'mycustomfuture'
    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_mycustomfuture_conditions',1,2);
    function my_em_scope_mycustomfuture_conditions($conditions, $args){
    	$grace_period = '1 hour'; // How long to show events after ending
    	if( !empty($args['scope']) && $args['scope']=='mycustomfuture' ){
    		$start_date = date('Y-m-d',current_time('timestamp'));
    		$today = $start_date;
    		if ( date( 'd', strtotime( 'now' ) ) != date( 'd', strtotime( '-' . $grace_period, 'now' ) ) ) {
    			$end_time = '00:00:00';
    		} else {
    			$end_time = date( 'H:i:s', strtotime( '-' . $grace_period, current_time('timestamp') ) );
    		}
    		$conditions['scope'] = " (recurrence = 0 OR recurrence IS NULL)
    			AND (
    				event_start_date > CAST('$today' AS DATE)
    				OR
    				event_end_date > CAST('$today' AS DATE)
    				OR (
    					event_end_date = CAST('$today' AS DATE)
    					AND (
    						event_all_day = '1'
    						OR
    						event_end_time >= CAST('$end_time' AS TIME)
    					)
    				)
    			)
    		";
    	}
    	return $conditions;
    }

    Does anyone know if the code stopped working or if there is another way to achieve this?

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Which version of Events Manager are you using?

    Thread Starter Extrafino

    (@extrafino)

    Version 5.5.7.1

    Thread Starter Extrafino

    (@extrafino)

    So, is there a solution for a custom scope?

    Plugin Support angelo_nwl

    (@angelo_nwl)

    can I know if you are getting any error when you enable wp_debug or checking your php logs ?

    Thread Starter Extrafino

    (@extrafino)

    Yes, thank you for the hint with wp_debug.
    I got an error for the line checking the date, with the error ‘date() expects parameter 2 to be long, string given’
    Removing the ‘strtotime( ‘now’ )’ makes the scope work as expected since date will use the current time by default anyway.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom scope not working’ is closed to new replies.