Support

Home Forums Event Espresso Premium Error in adding filters when searching for records

Error in adding filters when searching for records

Posted: March 5, 2019 at 2:17 am


guiapenin

March 5, 2019 at 2:17 am

Good Morning,

This issue we already formulated in another post and we gave it as solved:

https://eventespresso.com/topic/add-new-filter-in-attendees-searcher/

but later we have noticed the following error.

When we add the following filters in the search of records, the result is limited to a single match, not to all matches as it happens without the filters

As you can see in the image, before adding the filters, the result of the search gives us three coincidences:

http://salonescopia.salonesguiapenin.com/wp-content/uploads/2019/03/busquedasinfiltro.jpg

After adding the filters, it only returns the first concidence and not the following ones.

http://salonescopia.salonesguiapenin.com/wp-content/uploads/2019/03/busquedaconfiltro.jpg

how can we solve this?

Thank you

The filter used is the one proposed by you:

}
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’][‘Answer.ANS_value’] = array(‘LIKE’, $search_string);
$where[‘OR*search_conditions’][‘Attendee.ATT_phone’] = array(‘LIKE’, $search_string);
$where[‘OR*search_conditions’][‘Transaction.Line_Item.LIN_desc’] = array(‘LIKE’, $search_string);
}
return $where;
}


Josh

  • Support Staff

March 5, 2019 at 9:26 am

Hi,

I don’t remember proposing that entire filter, just the last part with the transaction line items. Are you saying that the last part is causing the limited set, or is it the entire customization?

I’m afraid I’m not able to replicate this, all expected results are returned with and without the filter on my test site. Maybe what you could do is try removing one condition at a time to see if that makes a difference.


guiapenin

March 5, 2019 at 10:34 am

Thank you, Josh, you are right, you contributed the last part of the filter, the transaction, the rest we got from previous answers in the forum, but it is just when we add this last part to the filter when it fails.

$ where [‘OR * search_conditions’] [‘Transaction.Line_Item.LIN_desc’] = array (‘LIKE’, $ search_string);

With the two previous filters, one by one, or both at the same time, it works correctly and returns the five matches, adding the Transaction.Line_Item.LIN_desc filter combined with the Answer.ANS_value filter is when it only returns the first match. .. in this case, the term jordi appears only in the name and in the email …

$ where [‘OR * search_conditions’] [‘Answer.ANS_value’] = array (‘LIKE’, $ search_string);
$ where [‘OR * search_conditions’] [‘Transaction.Line_Item.LIN_desc’] = array (‘LIKE’, $ search_string);


Tony

  • Support Staff

March 6, 2019 at 2:42 pm

In short, it’s because of the multiple joins used in the query. When you join using the line items it’s returning a single row.

One way to try and prevent it is to set the GROUP BY statement on the query to REG_ID, however, we don’t have a filter you can use to set that field at this time and we previously removed that group by to allow sorting with multiple joins to function correctly.

I can request a filter is added to core that could be used to set the group by value but as it stands you’ll need to not run the above query using Transaction.Line_Item.LIN_desc

The support post ‘Error in adding filters when searching for records’ 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