Support

Home Forums Event Espresso Premium Registration Search Query

Registration Search Query

Posted: June 30, 2017 at 8:09 am


bewegt

June 30, 2017 at 8:09 am

Hello

I tried to apply the new filter for changing the search query in the registration page but it doesn’t work. Can you help me finding the error in this code?

add_filter('FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', 'my_custom_search_field_reg', 10, 1);
function my_custom_search_field_reg( $request ) {
  if (isset($request['s'])) {
    $search_string = '%' . sanitize_text_field($request['s']) . '%';
    $where['OR*search_conditions']['Event.EVT_ID'] = array('LIKE', $search_string);
    $where['OR*search_conditions']['Event.Post_Meta.meta_value'] = array('LIKE', $search_string);
  }
  return $where;
}

Thanks in advanced.

Regards,
Benjamin


Josh

  • Support Staff

June 30, 2017 at 11:56 am

Hi Benjamin,

The first two lines need a few fixes:

add_filter(
'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', 
'my_custom_search_field_reg', 
10, 
2
);
function my_custom_search_field_reg( $where, $request ) {

Heres’s a well-written tutorial that explains more about passing in variables and how (in example 2) :
http://dev.themeblvd.com/tutorial/filters/


bewegt

June 30, 2017 at 2:44 pm

Thanks, I cloud fix it. But the Event.EVT_ID isn’t working.

add_filter('FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', 'my_custom_search_field_reg', 10, 2);
function my_custom_search_field_reg( $where, $request ) {
  if (isset($request['s'])) {
    $search_string = '%' . sanitize_text_field($request['s']) . '%';
    $where['OR*search_conditions']['Event.EVT_ID'] = array('LIKE', $search_string);
    $where['OR*search_conditions']['Event.Post_Meta.meta_value'] = array('LIKE', $search_string);
  }
  return $where;
}

Did I something wrong?

Thanks a lot.


Josh

  • Support Staff

July 1, 2017 at 9:03 am

Hi there,

It works for me when I test the code. Can you explain exactly what you mean by “isn’t working”? For example is it not returning any results if you input a valid event ID?


bewegt

July 5, 2017 at 5:21 am

Sorry my bad, it’s working now.
Thanks a lot for your help.

The support post ‘Registration Search Query’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso