• Resolved blueflamman

    (@blueflamman)


    Hi there,

    Thank you so much for the awesome plugin! It has helped me get my site to almost be up and going.
    Just having an issue atm. I am using “Groups” with the “Woo-Groups” add-on in WooCommerce. I assign a group based on the product to add the client to the group once purchased. I am know trying to have them removed from multiple groups when they add a new product that contains the same content in a pack, which will also add them to the new group. However it seems to be adding them to the new group but not removing them from the old group.

    Any idea what would be causing this? or is this coming more from the WooCommerce side?

    • This topic was modified 6 years, 10 months ago by blueflamman.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kento

    (@proaktion)

    Hi,

    Great to hear that the plugin is useful for you, please don’t forget to rate it when you get a chance 🙂

    Regarding your question, the system won’t delete a user from a group if there is a valid order that grants access to it (the group).

    Maybe you could restructure your groups so that you don’t even need to remove them?

    Cheers

    Thread Starter blueflamman

    (@blueflamman)

    Thanks for your reply Kento,

    Is there any chance that this could be modified? i.e.- code added to override this? If this would be possible it would suit my needs perfectly. Maybe this could be an added feature? Either way, if you could help me with this I would be happy to pay you for your time.

    Plugin Author Kento

    (@proaktion)

    Yes it’s possible and involves some coding. You could use the groups_created_user_group action to remove the user from one group after having been added to another – details on the action are documented here http://docs.itthinx.com/document/groups/api/actions/

    Thank you very much for your offer, I think this simple solution won’t make it necessary though:

    add_action( 'groups_created_user_group', 'blueflamman_groups_created_user_group', 10, 2);
    function blueflamman_groups_created_user_group( $user_id, $group_id ) {
    switch( $group_id ) {
      case 123 :
        Groups_User_Group::delete( $user_id, 456 );
        break;
      case 234 :
        Groups_User_Group::delete( $user_id, 567 );
        break;
    }
    }

    This assumes that when a user is added to the group with ID 123, the user should be removed from the group with ID 456. Also when added to group with ID 234, removes it from group 567.

    You can drop this in your theme’s functions.php (IMPORTANT : make a full backup of your site and database first and rather test it on a staging site before you modify anything on your production site – I haven’t tested the above code and you need to adjust it to the groups and IDs for your particular site so please test it thoroughly before you deploy anything on your production site).

    Let me know how it works or if you have any questions, marking as resolved with the solution given above but please feel free to ask.

    • This reply was modified 6 years, 10 months ago by Kento. Reason: removed quotes
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘User Group assignment not updating’ is closed to new replies.