Public Ticket #3215480

What is the meta to assign a customer to an agent?

Closed
Comments
2 Tickets 1
Alexander started the conversation 4 years ago on January 24, 2023 at 9:08pm

Hello, I want to know what is the meta key that a customer registration form field must have to be assigned to an agent?

I have seen that this can be done with a predefined Sales Representative ID field, but I want to use a form of my own to the predefined one of woocommerce

2,762
KingsPlugins replied 4 years ago on January 25, 2023 at 4:27am

Hi Alexander,

Thank you for purchasing our plugin!


To assign a customer to an agent programmatically, you need to set the following user meta key:

salesking_assigned_agent 


The value of the meta key needs to be the USER ID of the agent that's assigned (For example 1234)

The user ID is found in the URL when you edit the agent:


get-user-id-in-wordpress-admin-url.png

Let me know if I can help with anything, or if you have any questions,

Kind regards,

Stefan



1
2 Tickets 1
Alexander replied 4 years ago on January 25, 2023 at 2:12pm

Thanks for your answer. It works very well.
I have another question.
It turns out that the ID that appears in the user edition page does not match the ID that appears in the agents dashboard, affiliate links page and, therefore, it does not work with the meta.

How could I make it work with that ID?

screenshots.


2,762
KingsPlugins replied 4 years ago on January 26, 2023 at 8:46am

Hmm, I see what you mean.


What do you use for the custom form? Do you have a way to run PHP code in the form?


Normally we are doing it like this in PHP:

$agent = get_users(array(
    'meta_key'     => 'salesking_agentid',
    'meta_value'   => $agent_id, // this is the ID in the Agent Dashboard
    'meta_compare' => '=',
    'fields' => 'ids',
));
$agent_user_id = $agent[0]; // this is the ID for the Meta Key
update_user_meta($customer_id,'salesking_assigned_agent', $agent_user_id);

We start with the agent ID in the dashboard and we get the standard user ID.



Sign In