You are here

function opigno_rules_add_role_to_user in Opigno 7

1 string reference to 'opigno_rules_add_role_to_user'
opigno_rules_action_info in ./opigno.rules.inc

File

./opigno.rules.inc, line 4

Code

function opigno_rules_add_role_to_user($role, $user, EntityDrupalWrapper $group) {

  // Load the user we want to add to the group
  $all_roles = og_roles('node', $group
    ->getBundle(), $group
    ->getIdentifier(), TRUE, TRUE);
  foreach ($all_roles as $role_id => $a_role) {
    if ($role == $role_id) {
      og_role_grant('node', $group
        ->getIdentifier(), $user->uid, $role_id);
    }
  }
}