ガーアー!(そして後で多くの髪を引っ張る)、ここに答えがあります:
カスタム モジュール ( myutil.module
) -.module
ファイルが空で、.info
他のモジュールに必要な同じスパース情報を含むファイル。
myutil.rules.inc
次のコードでファイルを追加します。
/**
* @file
* Rules code: actions, conditions and events.
*/
/**
* Implements hook_rules_action_info().
*/
function myutil_rules_action_info() {
$actions = array(
'myutil_action_send_email_to_group_editors' => array(
'label' => t('Get group editors from group audience'),
'group' => t('My Utilities'),
'configurable' => TRUE,
'parameter' => array(
'group_content' => array(
'type' => 'entity',
'label' => t('Group content'),
'description' => t('The group content determining the group audience.'),
),
),
'provides' => array(
'group_editors' => array('type' => 'list<user>', 'label' => t('List of group editors')),
),
'base' => 'myutil_rules_get_editors',
),
);
return $actions;
}
function myutil_rules_get_editors($group_content) {
if (!isset($group_content->og_membership)) {
// Not a group content.
return;
}
$members = array();
foreach ($group_content->og_membership->value() as $og_membership) {
// Get the group members the group content belongs to.
$current_members = db_select('og_membership', 'om');
$current_members->join('og_users_roles', 'ogur', 'om.etid = ogur.uid');
$current_members->fields('om', array('etid'));
$current_members->condition('om.gid', $og_membership->gid);
$current_members->condition('om.entity_type', 'user');
// FOR THIS LINE, YOU'LL NEED TO KNOW THE ROLE ID FROM THE `og_role` TABLE
$current_members->condition('ogur.rid', 14);
$result = $current_members->execute();
while ($res = $result->fetchAssoc()) {
$members[] = $res['etid'];
}
}
// Remove duplicate items.
$members = array_keys(array_flip($members));
return array('group_editors' => $members);
}
他のモジュールと同じようにモジュールを有効にします。キャッシュの消去。ルールに戻って楽しんでください。