eventsmanager

custom event attribute search

Mar 15th, 2013 (edited)
793
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * [events_list event_type="demo"]
  3. * replace attribute_name with your custom event attribute name
  4. */
  5.  
  6. function em_event_types_get_default_search($searches, $array)
  7. {
  8. if( !empty($array['event_type'])){
  9. $searches['event_type'] = $array['event_type'];
  10. }
  11. return $searches;
  12. }
  13. add_filter('em_events_get_default_search','em_event_types_get_default_search',1,2);
  14.  
  15. add_filter('em_events_get','em_event_types_events_get',1,2);
  16. function em_event_types_events_get($events, $args)
  17. {
  18. if( !empty($args['event_type'])){
  19. $event_types = explode(',', $args['event_type']);
  20. foreach($events as $event_key => $EM_Event){
  21. if( !in_array($EM_Event->event_attributes['attribute_name'], $event_types) ){
  22. unset($events[$event_key]);
  23. }
  24. }
  25. }
  26. return $events;
  27. }
RAW Paste Data