You are here

function og_rules_grant_og_role in Organic groups 7.2

Action: Grant OG role.

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

File

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

Code

function og_rules_grant_og_role(EntityDrupalWrapper $account, EntityDrupalWrapper $group, $roles) {
  $group_roles = og_roles($group
    ->type(), NULL, $group
    ->getIdentifier());
  foreach ($roles as $role) {
    $rid = array_search($role, $group_roles);
    if ($rid !== FALSE) {
      og_role_grant($group
        ->type(), $group
        ->getIdentifier(), $account
        ->getIdentifier(), $rid);
    }
  }
}