Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search in following user meta fields
This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years, 7 months ago.
- AuthorPosts
- October 12, 2019 at 9:37 pm #24305
The User Meta Fields documentation at
https://documentation.ajaxsearchpro.com/general-settings/search-in-users/user-meta-fields
does not match the user interface on the plugin.Moreover, despite entering user meta fields into
General Options -> User Search -> Search in following user meta fields
it will not return results for more than one meta field value at a time.Example of issue:
User meta field 1 color: red
Searching red returns all red usersUser meta field 2 size: small
Searching small returns all small usersBUT
Searching red small returns No Results for “red small”!October 14, 2019 at 9:35 am #24311Hi,
Thank you for noting the mismatch – the interface since had been updated to a more user friendly version, I have updated the documentation as well now.
With the default search phrase logic, searching “red small” will only return users where either of the selected fields match “red” and “small”. If there is no overlapping, then using the “OR” logic might be the better choice: https://i.imgur.com/dUNDRux.png
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 15, 2019 at 3:06 pm #24338Thanks for the reply.
But if there is overlapping, for example a user named “JOE” that has a meta field for color = red, AND a meta field for size = small, I’m assuming searching red small will return that user.
Presently,
1- searching red returns JOE
1- searching small returns JOE
1- searching red small returns No Results for “red small”!October 16, 2019 at 8:24 am #24345Interesting, I cannot seem to be able to replicate this fully. I have an idea though. Please try adding the following code to the functions.php file in your theme directory:
add_action('asp_query_args', 'asp_query_args_meta_changes'); function asp_query_args_meta_changes($args) { $args['user_search_meta_fields_separate_subquery'] = 1; return $args; }
This should force a separate keyword logic for the meta queries in the user search.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 18, 2019 at 12:13 am #24359Well this works, however it slows the search down considerably.
Too slow for production.October 18, 2019 at 9:33 am #24363Well, this is the main reason this feature is programatically disabled. Each meta query needs to run as a sub query in order to check the individual fields per phrase. In smaller databases usually it makes no difference, but it exponentially slows down as it grows.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.