3

I have just installed this plugin into our WP site and am trying to figure out how to property use the users endpoint to find a user by their username. I have tried the filter several different ways, but it keeps returning all users. Has anyone been able to accomplish this, and if so, what parameters need to be passed to properly setup the filter?

Here is the URL I am using http://www.example.com/wp-json/users?filter[orderby]=login&filter[s]=admin

I have tried it with and without the orderby parameter, which according to the docs, is supposed to determine what field the filter applies to. I have also tried setting the value of the orderbvy user_login.

Paul Zepernick
  • 1,452
  • 1
  • 11
  • 25
  • The reason I was doing this was to check if the user existed before creating it. However, it looks like the create user returns some json saying it already existed, so I think that will work for now. I would still like to know why this is not working in case I need it for something different in the future. – Paul Zepernick Apr 23 '15 at 18:30

3 Answers3

3

You can use the search argument

https://example.com/wp-json/wp/v2/users/?search=myusername
Brieuc
  • 3,994
  • 9
  • 37
  • 70
0

I have had the same problem, so I have created extension plugin https://github.com/dest81/wp-api-get-user-by-username

0

You can filter by username directly:

https://example.com/wp-json/wp/v2/users/?username=jsmith

WP REST API Handbook

ksaylor11
  • 433
  • 4
  • 10