I have several group content types set up, but only want to allow a user to be a member of 1 group of each type (there may be 3 'admin' groups, but a user can only be a member of 1 admin group, but they can also be a member of a group of a different type - 'editor' for example).
I can't figure out how to target the user being added to the group in Rules. I'm trying to write a condition in PHP that takes the user, checks to make sure they aren't in a group of that type and if so, allows the group membership to be saved.
global $user;
gives me the user that is trying to add the person to the group (the current logged in user), which is what I thought it would do.
TL;DR - How can I get the user being added to a group in a custom PHP condition in Rules and NOT the current logged in user?
If you're working with Organic Groups in Rules, you can get the user you're adding to a group by using:
$og_membership->etid
This will give you the user id, which you can then load the user if needed.