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

php - Is it possible to create new user from external form using REST API?

programmeradmin2浏览0评论

I created a new user (called external) in a WordPress site with manage users capabilites. I installed Application Passwords plugin to generate a token for that user. Now is it possibile to create a simple HTML form on a NON WordPress website to send POST request to /wp/v2/users with external user credentials to create new users? Alternatively is it possibile to use "vanilla" PHP only or do I have to use JavaScript/jQuery with Ajax?

EDIT: reading around I understood I have to use cURL to do a POST request with PHP (in WordPress I' have used wp_remote_post(...)) but I never used cURL, how can "convert" a wp_remote_post call to a cURL POST request? How can I manage authentication?

I created a new user (called external) in a WordPress site with manage users capabilites. I installed Application Passwords plugin to generate a token for that user. Now is it possibile to create a simple HTML form on a NON WordPress website to send POST request to /wp/v2/users with external user credentials to create new users? Alternatively is it possibile to use "vanilla" PHP only or do I have to use JavaScript/jQuery with Ajax?

EDIT: reading around I understood I have to use cURL to do a POST request with PHP (in WordPress I' have used wp_remote_post(...)) but I never used cURL, how can "convert" a wp_remote_post call to a cURL POST request? How can I manage authentication?

Share Improve this question edited Sep 17, 2020 at 18:22 icolumbro asked Sep 17, 2020 at 17:37 icolumbroicolumbro 791 silver badge9 bronze badges 1
  • 1 would the browser be contacting the endpoint, or the non-WordPress server? Note that there are major security consequences that depend upon your answer to that question, if it's the browser that talks to the WP site, it'll need the application password to do so, which is a major security breach – Tom J Nowell Commented Sep 17, 2020 at 18:18
Add a comment  | 

1 Answer 1

Reset to default 1

If i'm not sure if i have misunderstand your question might, yes you need to send a post request to POST /wp/v2/users api. That should do the trick i dont think programming language have issue on this. I believe you should decide how post submitting flow should be affecting.

发布评论

评论列表(0)

  1. 暂无评论