How to add and delete a user to another group using the Group module? I am using Drupal 7 and the Group module. I would like to create  reaction rule or some code which automatically signs the user up to group 'blue', when they sign up to group 'red'.

I wouldn't mind using Rules or hard coding it. The only thing is that if the user leaves the first group, I want to be able to cancel their membership in the second group too.

What would be the easiest way? I have of course tried Rules without success and I cannot find a simple way to hard code it.
Found the solution. When using the group module, there are methods which work well. I used a hook_group_membership_insert($group_membership):

function [my_module]_group_membership_insert($group_membership) {

   $grouptest = group_load($group_membership-&gt;gid);
   $grouptest-&gt;addMember($group_membership-&gt;uid);
}


The same exists for deleting a member, just use the following function: 

$grouptest-&gt;removeMember($uid);