When a user requests to join an Organic Group, I want to send an email to the group's admins. I've found this answer (https://stackoverflow.com/questions/16742925/how-to-send-an-email-to-drupal-7-organic-groups-role-members/23301910) which helps with selecting users with the appropriate role, but I can't for the life of me get a list of just the users from the current group.
2 Answers
You don't need any of that php stuff tenken is saying. Just install Rules, create a new rule reacting on a user joining a group and use the action "Get group members from group audience". For this to work, you'll have to add to the conditions in the rule that the node is in fact a group.
-
1A screenshot of this approach can be seen in my question here: drupal.stackexchange.com/questions/190139/… Feb 12, 2016 at 11:15
Sounds like you need to:
- define a new variable in your Rule called
$users_in_group
. - use a
php script
step to use anEntityFieldQuery
or Organic Groups API call to list the users in a Group. - Assign
$users_in_group
to the result of your php-script business logic. - Use a
Rules Loop
to loop over the result array of$users_in_group
- use a final
php-script
rules step to do the logic you describe in your link for the appropriate user.