Support » Plugin: Events Manager » Location list using hooks/filters for custom fields

  • Resolved Thijsonline

    (@thijsonline)


    Context:

      Updated WordPress version from 3.5 to 4.9
      Updated Events manager from 5.4.3 to 5.9.3

    Using the code below (from this support topic) I’m trying to generate a list based on combinations of ‘Town’ and ‘Custom’, but this doesn’t work anymore (inconsistent results).

    add_filter('em_locations_get_default_search','my_em_cf_get_default_search',1,2);
    function my_em_cf_get_default_search($searches, $array){
    	if( !empty($array['custom']) ){
    		$searches['custom'] = $array['custom'];
    	}
    	return $searches;
    }
    
    add_filter('em_locations_get','my_em_cf_events_get',1,2);
    function my_em_cf_events_get($locations, $args){
    	if( !empty($args['custom']) ){
    		foreach($locations as $location_key => $EM_Location){
    			if( !in_array($args['custom'],$EM_Location->location_attributes) ){
    				unset($locations[$location_key]);
    			}
    		}
    	}
    	return $locations;
    }

    By inconsistent I mean:
    1) the combination of ‘Town’ and ‘Custom’ generates results in some cases, not in others
    2) ‘Town’ alone generates results but not all
    3) ‘Custom’ alone generates results but not all

    Is above code in functions.php still supposed to work (used to work before updating)?

    Tips on what else might be driving the problem are very much appreciated (I realize the upgrades I did cover structurally changed versions of both WP and EM).

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Location list using hooks/filters for custom fields’ is closed to new replies.