Okay
  Public Ticket #2977767
Update set Role on Customer Creation
Closed

Comments

  •  1
    Kris started the conversation

    Is there a way to set a specific role when a Sales Agent creates a new customer?

    We have added on to the standard Woocommerce 'My Account' page to show specific information when the user's role is set to one we created called 'Dealer'.

    Is there a way for that Add a Customer feature in the Sale Agent Dashboard, to auto-set the new Customer to that role?

  •  2,214
    WebWizards replied

    Hi Kris,

    Thank you for purchasing our plugin,


    You can achieve this by adding the following PHP code snippet to the site.

    add_action('salesking_after_customer_created', function($customer_id){
        $userobj = new WP_User($customer_id);
        $userobj->set_role('dealer');
    }, 10, 1);
    

    A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


    Let me know if that works for you, and if there's anything I can help with,

    Kind regards,

    Stefan

  •  1
    Kris replied

    Perfect! Worked Thank you!