0

I have about 1,500 user accounts (subscribers). When I go to the Users section of the WP admin/backend area, and then try to search for a user, it is very unreliable. If I search for a last name or first name that I know is there, it often doesn't return that user. Or, it will return a few users with that same last name, but not all of them.

Is there some sort of limit on the number of users that WP can search? The search does seem to be reliable when I search by email address, but not by name. For example:

I have a user named Sharon Williams. I searched for "Williams", and she appeared. I searched for "Sharon" and she did not. I searched for "Sharon Williams" and she did not.

Additionally, I have a user name John Williams. He did not show up in the search for "Williams", "John" OR "John Williams".

They both show up if I search by their exact email address.

Any ideas what's going wrong? I'm not getting any errors or timeouts that I can see.

0

I don't believe you are doing anything wrong, I think it is the way the get_users function works https://codex.wordpress.org/Function_Reference/get_users...

search - Use this argument to search users by email address, URL, ID, username or display_name.

Perhaps the phrases you are searching with do not match any of the above as it needs to be a full match unless you use the * wildcard which you can add before, after your search string (or both).

From the above codex link the codex link...

You can also do wild card search by adding an * before or after your search query. For example, to search for all users that start with "jo", you would pass something like "jo*".

The results will be all users whose user names, IDs, or emails that start with "jo". The * can be placed before or after your search query. When placed before, the results will be all users that end in your query.

  • Thanks Mike. This makes sense, but unfortunately the wildcard isn't returning different results with or without the asterisk. For example, I tried it with my John Williams user, and an asterisk before or after "John" or "Williams" still didn't return him. It gave the same results as if I had not included the asterisk. – LBF Aug 21 '15 at 17:33
  • Is there a way to extend the default search to also search for first name and last name? – LBF Aug 21 '15 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.