admin管理员组

文章数量:1417426

I'd like to call WP REST API to update a user. I have only username, so I suppose I should retrieve user ID first of all, as the endpoint for updating a user is:

GET /wp/v2/users/<id>

How to retrieve the ID with username (that is unique as well)?

I tried:

GET /wp/v2/users/?username=USERNAME 

but it's not working.

I also tried:

GET /wp/v2/users/?slug=USERNAME

and it works, but I'm not sure it would not return duplicates.

The best would be update directly the user with a single call, with the username as key, but if this is not possible, I would like to be sure 100% the retrieved ID is the one of the unique username I provided.

本文标签: How to update a user with REST API v2 knowing only the username