Public Ticket #4522309

Auto Role Assignment When Adding Customers Through SalesKing

Closed
Comments
13 Tickets
Marcus started the conversation 10 months ago on December 2, 2025 at 4:12pm

Hi Team,

Hope you’re doing well. I have a quick question regarding customer role assignment.

When a new customer is added through the “My Customers” section in the SalesKing agent dashboard, the system currently assigns the default WooCommerce role Customer.

Is it possible to automatically assign a different role instead—for example, Referred Customer—whenever a customer is created from this interface?

Appreciate your guidance on whether this can be configured natively or if a custom hook is required.

Thank you!

2,762
KingsPlugins replied 10 months ago on December 3, 2025 at 7:18pm

Hi Marcus,

Glad to assist,

There is no native setting to change the default role specifically for customers added by agents, but you can achieve this using a code snippet.

We have a hook called salesking_after_customer_created that runs immediately after the agent creates the user. You can use this to force a specific role for those users.

 

Here is an example snippet that assigns a "Referred Customer" role:

add_action('salesking_after_customer_created', function($user_id){

    $user = new WP_User($user_id); // Replace 'referred_customer' with the actual slug of your custom role 

    $user->set_role('referred_customer'); 

}, 10, 1);

You can add this to your child theme's functions.php file or by using a code snippets plugin. Please make sure to update referred_customer in the code to match the actual slug of the role you created.

 

Kind regards,
Stefan

1

Sign In