最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to update a user with REST API v2 knowing only the username?

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论