@prionkor
By default, if not specified, the role for new users is customer
if you have WooCommerce installed and subscriber
if you don’t.
You can pass a role
argument in your request to set different roles, but the role has to exist and can’t be admin (administrator, editor, author).
If you have WC installed and your new users are not being created as customer
by default, you may have something in your installation that is causing this.
Either you have some plugin forcing the role of new users to be subscriber
or for some reason your WC is not being detected as installed and activated.
—
To help you debugging this, you can edit class-wp-rest-user-public.php
, line 132, and change from this:
$user_id = username_exists($username);
To this:
$wc_detected = class_exists('WooCommerce') ? 'yes' : 'no';
$role_passed = empty($role) ? '<none>' : $parameters['role'];
$error->add(405, "Role: $role; Role passed: $role_passed; WC detected: $wc_detected; ");
return $error;
$user_id = username_exists($username);
This will display if it has detected WC, if has detected any role passed by argument, the role that is going to be set.
—
Another way to troubleshoot this is to deactivate all your plugins except for WooCommerce and WC-REST-User.