Duplicate the customer user roles in woocommerce via code

In particular cases, it can be useful to add a user roles group cloned.
As you know the default groups in Worpress are Administrator, Editor, Author, Contributor, Subscriber.
Woocommerce adds the following: Shop manager and Customer.
The following code lets you create a new User Roles group base on cloning the customer roles:

//AGGIUNGERE RUOLO
add_action('init', 'cloningcustomer');

function cloningcustomer()
{
    global $wp_roles; 
    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles();

    $adm = $wp_roles->get_role('customer');
    $wp_roles->add_role('business_user', 'Business User', $adm->capabilities);
}

Questions? Suggestions? Please leave a comment below.

Leave a comment