I am using WP_User_Query
to search use by name, ID, email etc…
In that case I need to use search_columns
field to pass ID or email of user.
What i am doing is
$my_users = new WP_User_Query(
array(
'role' => $role,
'offset' => $offset ,
'number' => $number,
'fields' => 'all',
'search_columns'=> array( '5','', 'johndoe_dd@yahoo1.com','',''),
//'search_columns'=> $search_columns_array,
'meta_query' => $meta_query_array,
));
For reference http://wpsmith.net/2012/wp/an-introduction-to-wp_user_query-class/
This is covered in the link you reference: The
search_columns
attribute does not set what should be searched for in each column, but instead specifies which columns should be searched for the term set in ‘search’.Specifically, you can only search for one term – but you can look in one or more columns.
From the source, the default values are:
user_email
– if an ‘@’ is present in the search termuser_login
,ID
– if not, but the term is numericuser_url
– if not, but the term looks like an url (and you have less than 10000 users).user_login
anduser_nicename
The source: