Public Ticket #2977767

Update set Role on Customer Creation

Closed
Comments
2 Tickets 1
Kris started the conversation 5 years ago on February 9, 2022 at 9:54pm

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,762
KingsPlugins replied 5 years ago on February 9, 2022 at 11:36pm

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://b2bkingplugin.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

Sign In