Hi,
I have still the same problem…
After some searching, I discovered that this code/search request:
//search args
$args = array(
'blog_id' => $GLOBALS['blog_id'],
'orderby' => 'user_nicename',
'order' => 'ASC',
'search' => $search,
'count_total' => true,
'fields' => 'all',
'number' => '',
'meta_key' => '',
'meta_value' => '',
'meta_compare' => '',
'meta_query' => array(),
);
//get the users and diplay them
$blog_users = get_users($args);
Results in this query by the WordPress-core:
SELECT wp_users . *
FROM wp_users
INNER JOIN wp_usermeta
ON wp_users
.ID
= wp_usermeta
.user_id
WHERE ‘1’ = ‘1’
AND (
(
wp_usermeta
.meta_key
= ‘wp_s2member_subscr_id’
AND wp_usermeta
.meta_value
LIKE ‘%asdf%’
)
OR (
wp_usermeta
.meta_key
= ‘wp_s2member_custom’
AND wp_usermeta
.meta_value
LIKE ‘%asdf%’
)
OR (
wp_usermeta
.meta_key
= ‘wp_s2member_custom_fields’
AND wp_usermeta
.meta_value
LIKE ‘%asdf%’
)
OR (
wp_usermeta
.meta_key
= ‘wp_s2member_notes’
AND wp_usermeta
.meta_value
LIKE ‘%asdf%’
)
OR (
wp_usermeta
.meta_key
LIKE ‘%_name’
AND wp_usermeta
.meta_value
LIKE ‘%asdf%’
)
OR user_login
LIKE ‘%asdf%’
OR user_nicename
LIKE ‘%asdf%’
OR user_email
LIKE ‘%asdf%’
OR user_url
LIKE ‘%asdf%’
OR display_name
LIKE ‘%asdf%’
)
AND wp_users
.ID
IN (
SELECT DISTINCT (
user_id
)
FROM wp_usermeta
WHERE meta_key
= ‘wp_capabilities’
)
ORDER BY user_nicename
ASC
LIMIT 0 , 30
Looking at all those OR fields to search for, I understand that there are so many results. So what am I doing wrong? My goal is to search for all users with that name in them.
Tanks in advantage,
Kinds regards,
Sven