Home » WooCommerce: Change User Role for New Customers

WooCommerce: Change User Role for New Customers

by Tutor Aspire

If you don’t want to assign the WooCommerce user role “customer” to new… customers, there is simple PHP that can be added to your functions.php to achieve this. Enjoy!

Change WooCommerce user role upon registration

PHP Snippet: Change User Role for New Customers – WooCommerce

/**
 * @snippet       Change User Role for New Customers - WooCommerce
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WC 4.6
 * @donate $9     https://www.tutoraspire.com
 */
 
///////////////////////////////
// 1. ADD NEW ROLE
 
add_role( 'pending', __( 'Pending' ), array(
  'read' => true, 
));
 
///////////////////////////////
// 2. ASSIGN NEW ROLE
 
add_filter( 'woocommerce_new_customer_data', 'tutoraspire_assign_custom_role' );
 
function tutoraspire_assign_custom_role( $args ) {
  $args['role'] = 'pending';
  return $args;
}

You may also like