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!

PHP Snippet: Change User Role for New Customers – WooCommerce
/**
* @snippet Change User Role for New Customers - WooCommerce
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WC 4.6
* @community https://businessbloomer.com/club/
*/
///////////////////////////////
// 1. ADD NEW ROLE
add_role( 'pending', __( 'Pending' ), array(
'read' => true,
));
///////////////////////////////
// 2. ASSIGN NEW ROLE
add_filter( 'woocommerce_new_customer_data', 'bbloomer_assign_custom_role' );
function bbloomer_assign_custom_role( $args ) {
$args['role'] = 'pending';
return $args;
}
Hi Rodolfo,
What if you wanted to add multiple user roles when a new customer is created?
Thank you,
Blair
Haven’t tested it, so let me know:
Is there a way to add the customer role, but only for the purchase of specific products? For example, we have a few subscription products and when users purchase these products, we want their user role to be Member. We installed the Woocommerce extension for Ultimate Member and it works when users checkout with credit card. However, users who checkout with mail-in check or ACH do not get their role changed when checking out.
Hi Dan, did you try manually completing those orders?
Hey Rodolfo, you have an un-closed tag in your post. Thanks for the snippet!
Thank you so much! Fixed.
I have been testing this out and it worked. But i want new users to get ” support” level to send tickets throught awesome support, not gonna spend 50 euros on a ” intergration” but now i see after playing around with it for a few hours that it first create a new role and then applys it to a new costumer, is there a snipit that gives new costumers that registate the role support or above?
Hi Daijiro, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi, Rodolfo. I was looking for that, thank you so much.
If I only want this to happen in register but not in checkout is that possible?
Thank you.
Hi Eli, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
What is the benefit of add this role?
Hey Abd, thanks for your comment! For example, my client needed to approve “Trade” users before allowing them to purchase (as normal customers). So this snippet changes that user role and give the Admin the option to approve them manually π
Hi again, Thanks for replying. Sounds cool. Well, I didn’t get notification of your reply I came back to your site to check for reply. WP core version doesn’t send notification of comments you may consider using this plugin https://wordpress.org/plugins/comment-reply-email-notification/ that will allow your user to get notified when you post a reply. Regards, Abd Ur Rehman
Thank you – it seems the others are receiving emails, weird π Is the email address you entered correct, and if yes, is there anything in your spam?