Search feature by metadata using custom table for usermeta
-
Due to a relatively high amount of users on a wordpress site, I had to enable the custom table for usermeta option in Ultimate Member plugin, to speed up displaying the member directory results, which took ages to load without turned this feature on.
Since that, load time is significantly better, but a previously used and working code snipppet – based on this issue – to filter out search results based just on first_name meta does not work anymore:add_filter( ‘um_prepare_user_query_args’, ‘my_user_before_query_usrs’, 10, 2 );
function my_user_before_query_usrs( $query_args, $directory_settings ){
global $current_user;
get_currentuserinfo();$current_user = wp_get_current_user();
if( isset( $_POST[‘search’] ) && $_POST[‘search’] != ” ) {
$query_args[‘search_columns’] = array( ‘first_name’ );
$query_args[‘search’] = ‘*’ . $_POST[‘search’] . ‘*’;
}
return $query_args;
}According to a previous post it looks like this feature was not available that time the issue was created, however I’m in need to solve this case to avoid getting false records in search results.
Please lead me to the right direction what should be modified to have a working condition again.
- The topic ‘Search feature by metadata using custom table for usermeta’ is closed to new replies.