I am building the WordPress Website with the wholesale registration.

On woocommerce Account Page, I am registration the user as a wholesaler and once anyone login I manually check the wholesale user details like retailer license number and business license and approve the users I am doing this with some extra fields.

In my Theme, I have added this code

add_filter('woocommerce_new_customer_data', 'wc_assign_custom_role', 10, 1);
function wc_assign_custom_role($args){
    $args['role'] = 'wholesale_customer';
    return $args;

which helps me to set the role for every new registration. Now my issue is:

I want to allow the user to register as a regular customer whole they checkout. I don't want them to register as a wholesale.

I am able to hide the additional fields from checkout user registration page using this code in my functions.php

'user_street' => array(
    'type'        => 'text',
    'label'       => __( 'Street', 'iconic' ),
    'hide_in_checkout'     => true,
    'sanitize' => 'wc_clean',
    'requiredI    => true,

but how i can set the separate user role when someone signup from checkout page?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.