I have an Organic Groups / subgroups structure where an Organisation is a group, a Property is a child group of an Organisation, and a claim is a child group of a property. So: Organisation > Property > Claim Each subgroup is set to inherit its parents users
When a new Property is created, I can use rules to 'Get group members from group audience' to email all of the members of the group:
However when a new Claim is created the same rule only emails the user who created the Claim. I think that this might be because inherited users are handled differently from normal users. You can see this by going into the 'group' tab on the claim and then clicking on people:
We can see in the screenshot above that there are three inherited users, but only the user who created the node will be emailed, the other two will not.
How should I email the inherited users when subgroups like Claim are created?
-- Addition --
og_subgroups.views.inc is used to create the view shown above. The contents of this file are:
function og_subgroups_views_pre_render(&$view) {
if ($view->name == 'og_members_admin') {
// Add an overview of the users that are inherited from parent groups.
$inherited_users = _og_subgroups_get_inherited_users($view->args[0], $view->args[1]);
$header = array('Name', 'Inherited from');
$rows = array();
$membership_states = og_group_content_states();
if (!empty($inherited_users)) {
foreach ($inherited_users as $inherited_uid => $data) {
$row = array();
$row[] = l($data[0]['user']->name, 'user/' . $inherited_uid);
$inherited_from = array();
foreach ($data as $inheritance) {
$inherited_from[] = t('!parent (@roles)', array(
'!parent' => l(entity_label($inheritance['inherited_from']['type'], $inheritance['inherited_from']['entity']), 'group/' . $inheritance['inherited_from']['type'] . '/' . $inheritance['inherited_from']['id'] . '/admin/people'),
'@roles' => implode(', ', $inheritance['roles']),
));
}
$row[] = implode(', ', $inherited_from);
$rows[] = $row;
}
}
$view->attachment_after = theme('table', array(
'caption' => t('Inherited users'),
'header' => $header,
'rows' => $rows,
'empty' => t('No inherited users.'),
));
}
}
It would be great if someone could suggest how I might be able to use the above code in rules. It would be great if I could use'Execute custom PHP code' and use something like
$inherited_users = _og_subgroups_get_inherited_users($view->args[0], $view->args[1]);
but that doesn't work in a custom PHP block in Rules. I can see the function _og_subgroups_get_inherited_users
in og_subgroups.common.inc and am not sure if I can use this code to help.
Using Organic Groups 7.x-2.7 and Organic groups subgroups 7.x-2.0-beta1