You are here

function og_rules_get_members in Organic groups 7

Same name and namespace in other branches
  1. 7.2 og.rules.inc \og_rules_get_members()

Action: Get group members from a group content.

1 string reference to 'og_rules_get_members'
og_rules_action_info in ./og.rules.inc
Implements hook_rules_action_info().

File

./og.rules.inc, line 232
Rules integration for the Organic groups module.

Code

function og_rules_get_members($group_content) {
  if (!isset($group_content->og_membership)) {

    // Not a group content.
    return;
  }
  $members = array();
  $gids = array();
  foreach ($group_content->og_membership
    ->value() as $og_membership) {

    // Get the groups the group content belongs to.
    $gids[] = $og_membership->gid;
  }
  if (!$gids) {
    return;
  }
  foreach ($gids as $gid) {
    $wrapper = entity_metadata_wrapper('group', $gid);
    $members = array_merge_recursive($members, $wrapper->members
      ->value(array(
      'identifier' => TRUE,
    )));
  }
  return array(
    'group_members' => $members,
  );
}