Your cart is currently empty!
Automatic assignment to a group
—
by
Hi itthinx team,
I have a question regarding the Groups plugin that I use.
Working with the Affiliates PRO and Groups plugins, I would like to achieve the following:
– A new customer visits my store from an affiliate partner URL
– The customer completes their order
– The customer is automatically assigned to the group that the referring Affiliate belongs to
Is there a way using the settings that the plugins provide to automatically assign a new customer to a group or this can happen only programmatically with custom code?
Thank you for looking into this!
Best,
Rudy
Posted in Affiliates Pro, Groups
Comments
3 responses to “Automatic assignment to a group”
Hello, Rudy,
It is not possible to achieve your desired functionality through plugin settings, I’m afraid.
It would require custom coding, like you suggested. There’s a code snippet here -> https://github.com/eggemplo/Affiliates-Auto-Group, that works to automatically add a new Affiliate to a certain group upon affiliate registration, perhaps it could work as a starting point in your case, but it’d be great if you would share some more details on what the desired outcome should be.
For example, in your scenario, what would you like to happen if the referring affiliate is a member of not one group, but several – should the new customer become a member of all the groups, or just a certain one?
Also, would that apply to affiliates that were referred by another affiliate, or just to new customers that were referred?
Cheers,
Denitsa
Hi Denitsa,
Thank you for the detailed answer! In my case I have the following Groups structure:
* Main group A
– Affiliate 1 Sub Group
– Affiliate 2 Sub Group
– ….more affiliate groups
Lets assume we’re Affiliate 1 and we belong to the Affiliate 1 Sub Group and the Main group A
We share our affiliate URL with a customer, who ends up creating an order. My idea was to have the customer assigned automatically to the Affiliate 1 Sub Group, just like they are automatically assigned to the Registered group.
If I can achieve this programmatically it would make sense (as in the example you kindly shared) to use an Action, perhaps affiliates_referral?
Best Regards,
Rudy
Hello, Rudy,
I sincerely apologize for the great delay in response on my end – the topic got buried somehow I have missed your reply.
So, assuming that your customer is not actually going to be an affiliate, then, yes, you can try using the affiliates_referral action and you’d need to get the groups that the referrer belongs to, the following code is an example of how this could be achieved:
$groups_user = new Groups_User( get_current_user_id() );
// get group objects
$user_groups = $groups_user->groups;
// get group ids (user is direct member)
$user_group_ids = $groups_user->group_ids;
// get group ids (user is direct member or by group inheritance)
$user_group_ids_deep = $groups_user->group_ids_deep;
Adding a user to those groups could be done like in the Affiliates-Auto-Group code that I shared, however, you’d have to check if the customer already belongs to that group/groups.
Cheers,
Denitsa