WooCommerce Change User Role On Registration

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

This code snippets changes the user role upon registration. By default, users are assigned the “Customer” user role. This snippet allows you to change that and assign a different user ole. In this specific example, we change the user role to “Contributor”. If you wish to assign a custom user role, you will first need to create this role. Search our guides on user roles to see how to create new user roles and apply certain capabilities.

				
					/**
 * Snippet Name:	WooCommerce Change User Role On Registration
 * Snippet Author:	ecommercehints.com
 */
  
// Change the default 'Customer' role to 'Contributor'.  
add_filter( 'woocommerce_new_customer_data', 'ecommercehints_change_user_role_on_registration' );
function ecommercehints_change_user_role_on_registration( $args ) {
  $args['role'] = 'contributor';
  return $args;
}
				
			

Snippet Benefits

  • Automatically change the user role upon registration
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers