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?

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

1 Answer 1

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.

2
  • 1
    This should do the job, but, do not do it in javascript, or anybody who can see the form will have the application password, and will be able to wield administrator level priviledges over the WP site and can create as many users as they want, delete them, edit them, etc
    – Tom J Nowell
    Commented Sep 17, 2020 at 18:19
  • I edited my original post...
    – icolumbro
    Commented Sep 17, 2020 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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