Automatic assignment to a group

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

3 Responses to Automatic assignment to a group

  1. Denitsa July 4, 2019 at 2:59 pm #

    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

    • Rudek July 5, 2019 at 6:53 am #

      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

      • Denitsa July 17, 2019 at 12:49 pm #

        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

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share