Set WooCommerce Default User Registration Role


Learn why I switched to WPCodeBox for managing code snippets for myself and for my clients.


Snippet Type: PHP

  1. Copy the snippet.
  2. Add the snippet using WPCodeBox.
  3. Follow any customization notes provided.
  4. Save the snippet.
  5. Enable the snippet.
  6. Test.


Customization Notes

In the example here, we are setting the default role to the ‘Subscriber’ role, and you can set your desired role by editing the ‘$args[‘role’] = ‘subscriber’;’ entry.

					// Set Woocommerce Default User Registration Role
add_filter('woocommerce_new_customer_data', 'wc_assign_custom_role', 10, 1);
function wc_assign_custom_role($args) {
  $args['role'] = 'subscriber';
  return $args;