On my website I have created a register page in react and I am using Wordpress headless with WooCommerce on it.

So I was expecting to create a new user using the register page i have and as the Wordpress side is by default set to create a 'Customer" user type for any new registration.

The registration is partially working. Let me explaining. To achieve the registration I have done this:

  • On wordpress, I have installed the plugin : WP Rest user from Sk8tech
  • I have called the api /wp-json/wp/v2/users/register with a body which contain the username, email and passwork.
  • The new user is created and have the "Customer" type

However this new user do not shows up in the WooCommerce Customer Dashboard.

When I have installed the WooCommerce plugin, at first, I have change the type of user manually through the Wordpress dashboard from subscriber to customer and they all shows up in the Customer part.

I have notice that WooCommerce do have an api to create a new customer /wp-json/wc/v3/customers but I cannot setup a password.

So Do I have to make 2 calls and the WooCommerce one, will automaticall create a new customer ?


1 Answer 1


In the documentation of WP REST User https://wordpress.org/plugins/wp-rest-user/ you have the aswer:

To perform further actions after user is registered, write and add_action:

add_action('wp_rest_user_user_register', 'user_registered');
function user_registered($user) {
    // Do Something

Replace "// Do Something" for the code to change the user role. Something like this (not tested):

$u = new WP_User( 3 ); //set your user ID
// Remove role
$u->remove_role( 'subscriber' );
// Add role
$u->add_role( 'customer' );
  • thanks but in my case the user is already seen as a "Customer" as a role in the wp dashboard but it's not showing up in the WooCommerce Customer dashboard
    – Seb
    Aug 31, 2020 at 16:09

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.