This is my code, that is searching FIRST name and LAST name.
/**
* Place this in your theme's functions.php file
* Or a site-specific plugin
*
*/
// Switch the WP_User_Query args to a meta search
function kia_meta_search( $args ){
// this $_GET is the name field of the custom input in search-author.php
$search = ( isset($_GET['as']) ) ? sanitize_text_field($_GET['as']) : false ;
if ( $search ){
$args = array (
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'first_name',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'last_name',
'value' => $search,
'compare' => 'LIKE'
)
)
);
// need to unset the original search args
if( isset( $args['search'] ) ) unset($args['search']);
}
return $args;
}
add_filter('sul_user_query_args', 'kia_meta_search');
——————————————————————–
But when using the search function, no matter id I change the orderby code: simple-user-listing.php:
$defaults = array(
'query_id' => 'simple_user_listing',
'role' => '',
'role__in' => '',
'role__not_in'=> '',
'include' => '',
'exclude' => '',
'blog_id' => '',
'number' => get_option( 'posts_per_page', 10 ),
'order' => 'ASC',
'orderby' => 'first_name',
'meta_key' => '',
'meta_value' => '',
'meta_compare' => '=',
'meta_type' => 'CHAR',
'count_total' => true,
'taxonomy' => '',
'terms' => ''
);
It always orderby the login name… how can I change that?