• Resolved prionkor

    (@prionkor)


    Is it possible to add customers instead of subscribers? I don’t see any settings for this plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter prionkor

    (@prionkor)

    Apparently you can send role parameter like this:

    
    {
    	"username": "testuser",
    	"email": "test@gmail.com",
    	"password": "333333",
    	"role": "customer"
    }
    
    Thread Starter prionkor

    (@prionkor)

    But when I send with role customer it adds as subscriber. I have woo commerce installed.

    @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.

    Thread Starter prionkor

    (@prionkor)

    I had to change default user role to customer in WordPress settings. Otherwise even if I sent ‘role’ => ‘customer’ it was ignored.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Woocommerce Support – Adding Customer instead of Subscriber’ is closed to new replies.