Black Friday 2026: up to 50% off today See Deals Dismiss

Reserve Your Free Seat for Our Next WooCommerce Class! Search
Business Bloomer
  • Join
  • WooCommerce Plugins
  • WooCommerce Tips
  • Log In
  • 0
  • Business Bloomer Club
  • WooCommerce Plugins
  • WooCommerce Tips
  • Log In
  • Search
  • Contact
  • Cart
WooCommerce Code Snippets Customer Registration My Account User Roles

WooCommerce: Change User Role for New Customers

Last Revised: Dec 2020

STAY UPDATED

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        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;
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Separate Login, Registration, My Account Pages
    There are times when you need to send logged out customers to a Login page and unregistered customers to a standalone Register page. As you…
  • WooCommerce: Add New Tab @ My Account Page
    One of the features of Business Bloomer Club is the provision of Premium WooCommerce Q&A Support to supporters who enroll. So, how to add an…
  • WooCommerce: Disable Payment Gateway for Specific User Role
    You may want to disable payment gateways depending on the logged in user role. For example, you may want to disable PayPal for user role…
  • WooCommerce: How To Make A Website GDPR Compliant? (12 Steps)
    Ok, we all know that the EU General Data Protection Regulation (GDPR) will come into force on the 25th May 2018. So the main question…
  • WooCommerce Visual Hook Guide: My Account Pages
    Hey WooCustomizers, the Visual Hook Guide is back 🙂 In this episode, I’ve created a visual HTML hook guide for the WooCommerce Account Pages (there…

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

14 thoughts on “WooCommerce: Change User Role for New Customers”

  1. Blair Davidson
    February 21, 2025

    Hi Rodolfo,

    What if you wanted to add multiple user roles when a new customer is created?

    Thank you,

    Blair

    Reply
    1. Rodolfo Melogli
      February 24, 2025

      Haven’t tested it, so let me know:

      $args['role'] = array( 'pending', 'another_role' );
      
      Reply
  2. Dan
    May 29, 2020

    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.

    Reply
    1. Rodolfo Melogli
      June 2, 2020

      Hi Dan, did you try manually completing those orders?

      Reply
  3. David
    September 26, 2019

    Hey Rodolfo, you have an un-closed tag in your post. Thanks for the snippet!

    Reply
    1. Rodolfo Melogli
      September 30, 2019

      Thank you so much! Fixed.

      Reply
  4. daijiro
    June 9, 2019

    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?

    Reply
    1. Rodolfo Melogli
      June 20, 2019

      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!

      Reply
  5. Eli
    June 4, 2018

    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.

    Reply
    1. Rodolfo Melogli
      June 6, 2018

      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

      Reply
  6. Abd Ur Rehman
    March 5, 2017

    What is the benefit of add this role?

    Reply
    1. Rodolfo Melogli
      March 8, 2017

      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 🙂

      Reply
      1. Abd Ur Rehman
        March 9, 2017

        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

        Reply
        1. Rodolfo Melogli
          March 11, 2017

          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?

          Reply
Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Cancel reply

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


Search WooCommerce Tips

Popular Searches: Visual Hook Guides - Checkout Page - Cart Page - Single Product Page - Add to Cart - Emails - Shipping - Prices - Hosting

Recent Articles

  • WooCommerce: Simple Price Including/Excluding Tax Switcher
  • WooCommerce: Refund Request Button @ My Account
  • WooCommerce: Show or Hide Bank Accounts Based On Order
  • WooCommerce: Save Order Currency Exchange Rate
  • WooCommerce: Get Orders Containing a Specific Product

Latest Comments

  1. Rodolfo Melogli on WooCommerce: “Inconsistent tax settings” Error
  2. ARNo on WooCommerce: Attach Files (PDF, etc.) To Emails
  3. Rodolfo Melogli on WooCommerce: Only Allow 1 Product in the Cart

Find Out More

  • Become a WooCommerce Expert
  • Business Bloomer Club
  • WooCommerce Blog
  • WooCommerce Weekly
  • Contact

Contact Info

Ciao! I'm Rodolfo Melogli, an Italian Civil Engineer who has turned into an international WooCommerce expert. You can contact me here:

Twitter: @rmelogli

Get in touch: Contact Page

Business Bloomer © 2011-2025 - VAT IT02722220817 - Terms of Use - Privacy Policy

Cart reminder?

x