You are here

function og_role_grant in Organic groups 7

Same name and namespace in other branches
  1. 7.2 og.module \og_role_grant()

Grant a group role to a user.

Parameters

$uid: The user ID.

$rid: The role ID.

2 calls to og_role_grant()
og_migrate_og_migrate_upgrade_user in og_migrate/plugins/og_migrate/upgrade_user.inc
OG Migrate callback; Upgrade user subscription to groups.
og_ui_user_multiple_role_edit in og_ui/og_ui.module
Callback function for admin mass adding/ deleting a user role.

File

./og.module, line 2751
Enable users to create and manage groups with roles and permissions.

Code

function og_role_grant($gid, $uid, $rid) {

  // Get the existiong user roles.
  $user_roles = og_get_user_roles($gid, $uid);
  if (!in_array($rid, $user_roles)) {
    $role = new stdClass();
    $role->uid = $uid;
    $role->rid = $rid;
    $role->gid = $gid;
    drupal_write_record('og_users_roles', $role);
    module_invoke_all('og_role_grant', $gid, $uid, $rid);
  }
}