Hi people… 15 minutos later I did it. If someone needs the same, take note of this code. Now you can search by first name or last name in the same textfield.
This is how I did it:
search-author.php
<?php
/**
* The Template for displaying Author Search
*
* Override this template by copying it to yourtheme/simple-user-listing/search-author.php
*
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$search = ( get_query_var( 'first_name' ) ) ? get_query_var( 'first_name' ) : '';
?>
<div class="author-search">
<h2><?php _e('Search authors by name' ,'simple-user-listing');?></h2>
<form method="get" id="sul-searchform" action="<?php the_permalink() ?>">
<label for="as" class="assistive-text"><?php _e('Search' ,'simple-user-listing');?></label>
<input type="text" class="field" name="first_name" id="sul-s" placeholder="<?php _e('Search Authors' ,'simple-user-listing');?>" value="<?php echo $search; ?>"/>
<input type="submit" class="submit" id="sul-searchsubmit" value="<?php _e('Search Authors' ,'simple-user-listing');?>" />
</form>
<?php
if( $search ){ ?>
<h2 ><?php printf( __('Search Results for: %s' ,'simple-user-listing'), '<em>' . $search .'</em>' );?></h2>
<a href="<?php the_permalink(); ?>"><?php _e('Back To Author Listing' ,'simple-user-listing');?></a>
<?php } ?>
</div><!-- .author-search -->
functions.php
// 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['first_name'])) ? sanitize_text_field($_GET['first_name']) : false ;
if ( $search ){
// if your shortcode has a 'role' parameter defined it will be maintained
// unless you choose to unset the role parameter by uncommenting the following
// unset( $args['role'] );
$args = array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'last_name',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'first_name',
'value' => $search,
'compare' => 'LIKE'
)
)
);
}
return $args;
}
add_filter('sul_user_query_args', 'kia_meta_search');
// Register query var and whitelist with Simple User Listing
function kia_search_vars( $vars ){
$vars[] = 'first_name';
return $vars;
}
add_filter('sul_user_allowed_search_vars', 'kia_search_vars');
Hope it helps ??