Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rest_cannot_create_user - know how to allow rest to create users? #35

Open
amityweb opened this issue Feb 17, 2022 · 4 comments
Open

rest_cannot_create_user - know how to allow rest to create users? #35

amityweb opened this issue Feb 17, 2022 · 4 comments

Comments

@amityweb
Copy link

I know this is probably not related to code on here, but I can't find a solution online.

Using this code:

$user = [
    'username' => 'myusername',  
    'email' => 'user@email.co.uk',
    'password' => 'password',
];
$wordpress = wpClient();
$user = $wordpress->users()->save($user);

I get this error:

Client error: `POST https://mysite.co.uk/wp-json/wp/v2/users` resulted in a `401 Unauthorized` response:
{"code":"rest_cannot_create_user","message":"Sorry, you are not allowed to create new users.","data":{"status":401}}
@angelxmoreno
Copy link

Are you using the user login password or an application password? They are not the same thing. Take a look at https://wprestclient.readthedocs.io/en/latest/misc/application-password/ which talks about how to get an application password

@amityweb
Copy link
Author

This issue was such a long time ago I have no idea. I can't recall what website or how I fixed it.

Does it usually take 16 months for a reply 😂. Just close this now please so you can spend time improving response times 😃

But thanks for replying anyway, it's better than no reply!

@angelxmoreno
Copy link

@amityweb apologies for the confusing. I am not part of this project. I recently used it and came across a few issue. No "license use" was the biggest turn off. I ended up creating my own https://github.com/angelxmoreno/WPRestClient

I replied to your comment because i had the same issue and resolved it and just wanted to share the wealth.

@amityweb
Copy link
Author

amityweb commented Jun 11, 2023

Ahh ok, no problem, I thought you were part of the dev team. Sorry if my comment sounded negative! I DO thank you for replying! But I dont even remember the issue anymore or what website 😂.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants