• Resolved AdrianV

    (@adrian-verstuyft)


    Hi,
    1. I followed your solution for generating own scopes with a snippet in functions.php, but the awaited results don’t show up in my events list.
    Wanted to show all events in the next 3 month beginning today.

    The code is:

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions2',1,2);
    function my_em_scope_conditions2($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='vorschau' ){
    		$start_date = date('j-F-Y',current_time('timestamp'));
    		$end_date = date('j-F-Y',strtotime("+3 months", 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_scopes2',1,1);
    function my_em_scopes2($scopes){
    	$my_scopes = array(
    		'vorschau' => 'vorschau'
    	);
    	return $scopes + $my_scopes;
    }

    What’s wrong?

    2. What if I want to add another scope (all events from today)? What parts of the snippet must be changed?
    Thanks in advance for your help.

    https://www.ads-software.com/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hiya,

    That code certainly looks okay. Where did you place it?

    To add more, simply add to the array in your my_em_scopes2() function and add an extra IF statement in my_em_scope_conditions2()

    Thanks

    Thread Starter AdrianV

    (@adrian-verstuyft)

    As I mentioned above I put it in functions.php and then call the scope in my page with following shortcode:

    [events_list_grouped mode=”monthly” scope=”vorschau” category=”44″]

    Im really stuck since weeks now and my client gets really impatient.

    to 2. You mean simply like this?

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions2',1,2);
    function my_em_scope_conditions2($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='vorschau' ){
    		$start_date = date('j-F-Y',current_time('timestamp'));
    		$end_date = date('j-F-Y',strtotime("+3 months", 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))";
    	}
    	if( !empty($args['scope']) && $args['scope']=='heute' ){
    		$start_date = date('j-F-Y',current_time('timestamp'));
    		$end_date = date('j-F-Y',strtotime("+1 day", 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_scopes2',1,1);
    function my_em_scopes2($scopes){
    	$my_scopes = array(
    		'vorschau' => 'vorschau'
    	);
    	return $scopes + $my_scopes;
    }
    add_filter( 'em_get_scopes','my_em_scopes2',1,1);
    function my_em_scopes2($scopes){
    	$my_scopes = array(
    		'heute' => 'heute'
    	);
    	return $scopes + $my_scopes;
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Thread Starter AdrianV

    (@adrian-verstuyft)

    Got the solution. Oh my gosh!
    I used the time format: j-F-Y
    It works with time format: Y-m-d

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can't get own scope to work’ is closed to new replies.