You are here

function og_user_import_group_add in User Import 5.2

1 call to og_user_import_group_add()
og_user_import_pre_save in supported/og.inc
Implementation of hook_user_import_pre_save().

File

supported/og.inc, line 112

Code

function og_user_import_group_add($settings, $email, $fields) {
  if ($settings['setting'] != 'import') {
    return;
  }
  $account = user_load(array(
    'mail' => $email,
  ));
  if (!empty($settings['options']['existing_og_message'])) {
    $profile = user_import_profile_load($account);
  }
  $groups_subscribed = og_get_subscriptions($account->uid);
  $og_args = array(
    'is_active' => 1,
    'is_admin' => 0,
    'mail_type' => 0,
    'created' => time(),
  );
  foreach ($settings['groups'] as $group) {

    // is user member of group?
    if (!empty($group) && empty($groups_subscribed[$group])) {

      // subscribe to group
      og_save_subscription($group, $account->uid, $og_args);
      if (!empty($settings['options']['existing_og_message'])) {
        _user_import_send_email($account, $password, $profile, $settings['options']['existing_og_subject'], $settings['options']['existing_og_message'], $settings['options']['existing_og_markup'], $settings['options']['existing_og_css'], $settings['options']['subscribed']);
      }
    }
  }
  return;
}