Public Ticket #3721503

Auto add customer account as agent

Closed
Comments
2,762
KingsPlugins replied 2 years ago on September 10, 2024 at 1:50pm

Hello Darius,

Can you please clarify, do you mean that you'd like all accounts that register on the site to automatically become agents? What registration form are you using, can you share a link please?


Kind regards,

Stefan

2,762
KingsPlugins replied 2 years ago on September 12, 2024 at 11:08am

Thanks for clarifying,

We can achieve this by adding the following PHP snippet to the site:

function set_salesking_user_meta($user_id) {
    update_user_meta($user_id, 'salesking_user_choice', 'agent');
    update_user_meta($user_id, 'salesking_group', '1234');
}
add_action('user_register', 'set_salesking_user_meta', 10, 1);
add_action('woocommerce_created_customer', 'set_salesking_user_meta', 10, 1);

In the above code, we need to change 1234 with the ID of the salesking group. To find that ID, please go to the backend SalesKing groups page, edit the group, and check the number in the URL (e.g. ?post=1234), that number is the ID.

The 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/

Sign In