Group Module: Join & Remove users from user account/profile 2? I added an entityreference to the user's Account so users can select what group they want to join (checkboxes). They check it and via a rule, it automatically adds them to that group. I did this for multiple Group Types.

Now i need it to remove user (unsubscribe) from group if "unchecked". Right now users keep on getting added if they select a new checkbox, but they are not removed from the previous group.

How can the we remove them from the now unchecked group and add them to the newly checked rule?

I found how to delete all group subscriptions on one rule. However, it removes all subscriptions, even those not found in this entityreference. How can we limit to add/remove users from only these group types?

Willing to pay for support on this issue.

Thank you.
I solved this. :) 

I used the views_rules module to create a view that filtered a list of exactly what i needed (filtering the group type per user).

I then created a rule:


Before saving a user account
Condition if previous is equal to new saved (Negate). So it will only run if there are changes in the field in question.
Added View Loop i created. Add action > Delete entity mid from the view loop.


Done. This deletes or unsubscribes any unchecked boxes/groups.

Now to create any new memberships/subscriptions to selected groups...

I added condition...

-If field empty... do nothing

-Else

-Loop the field in question (gmem_created)

-Create new entity of type group membership

-Save a data value

Data: [gmem-created:group], Value: [account:field-yourgroup]

-Save a data value

Data: [gmem-created:user], Value: [account]

-Save entity

Entity: [gmem-created], Force saving immediately: true