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' => '[email protected]',
'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}}