You are here

function regcode_og_regcode_used in Registration codes 7

Same name and namespace in other branches
  1. 6.2 regcode_og/regcode_og.module \regcode_og_regcode_used()
  2. 6 regcode_og/regcode_og.module \regcode_og_regcode_used()
  3. 7.2 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 334
Install, uninstall and scheme functions for the regcode_og module.

Code

function regcode_og_regcode_used($regcode, &$account) {

  // Do nothing if the regcode is not valid.
  if (!is_object($regcode)) {
    return;
  }
  $settings = variable_get('regcode_og_settings', array());

  // Apply the rules.
  $tags = array_keys($regcode->tags);
  foreach ($settings as $rule) {
    if (in_array($rule['tid'], $tags)) {
      foreach ($rule['ogs'] as $ogid) {
        og_group('node', $ogid, array(
          'entity' => $account,
        ));
      }
    }
  }
}