Why do newly registered users get assigned customer roles?

I have a problem in which when newly registered users who register at checkout get assigned customer roles instead of subscribers, how can change that I tried going to setting > general, but even though the default tole was set to subscribers they still get assigned customers as their roles.

3 Comments
  1. By default on an e-commerce website (WooCommerce plugin for example), WordPress assigns the “customer” role to users who register through the checkout process.

    This is because those plugins creates a customer account for anyone who makes a purchase, and that customer account is created with the “customer” role.

    To change this behavior, you can use a plugin like “User Role Editor” ) to modify the default user role for newly registered users. This plugin allows you to change the default user role for new users and customize the capabilities of each user role.

    Alternatively, you can also use a code snippet to change the default user role for new users. To do this, you can add the following code to your theme’s functions.php file:

    “`
    function change_default_role($role, $user_id) {
    $role = ‘subscriber’;
    return $role;
    }
    add_filter(‘pre_user_role’, ‘change_default_role’, 10, 2);

    “`

    This code will change the default user role for all new users to “subscriber”.

    It’s important to note that you should always backup your website before making any changes, especially when modifying code or installing new plugins !

  2. WordPress does not have the role “customer” by default.\

    What ecommerce plugin are you using?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer