You are here

function regcode_og_regcode_used in Registration codes 6

Same name and namespace in other branches
  1. 6.2 regcode_og/regcode_og.module \regcode_og_regcode_used()
  2. 7.2 regcode_og/regcode_og.module \regcode_og_regcode_used()
  3. 7 regcode_og/regcode_og.module \regcode_og_regcode_used()

Implements hook_regcode_used()

Add the new role to the user

File

regcode_og/regcode_og.module, line 187

Code

function regcode_og_regcode_used(&$edit, &$account, $regcode) {

  // Do nothing if the regcode is not valid
  if (!is_array($regcode)) {
    return;
  }

  // Grab applicable roles for category used
  $rules = regcode_og_get_rules($regcode['category']);

  // Apply the rules
  if (count($rules)) {
    foreach ($rules as $rule) {
      og_save_subscription($rule['ogid'], $account->uid, array(
        'is_active' => 1,
      ));
    }
  }
}