You are here

function og_add_users_submit in Organic groups 6

Same name and namespace in other branches
  1. 5.8 og.module \og_add_users_submit()
  2. 5 og.module \og_add_users_submit()
  3. 5.2 og.module \og_add_users_submit()
  4. 5.3 og.module \og_add_users_submit()
  5. 5.7 og.module \og_add_users_submit()
  6. 6.2 og.pages.inc \og_add_users_submit()

File

./og.module, line 1194

Code

function og_add_users_submit($form, &$form_state) {

  // Safest option is to do a select, filter existing members, then insert.
  $names = explode(',', $form_state['values']['og_names']);
  foreach ($names as $name) {
    $account = user_load(array(
      'name' => trim($name),
    ));
    if ($account->uid) {
      $accounts[] = $account;
    }
  }
  foreach ($accounts as $account) {
    og_save_subscription($form_state['values']['gid'], $account->uid, array(
      'is_active' => 1,
    ));
  }
  drupal_set_message(format_plural(count($accounts), '1 user added to the group.', '@count users added to the group.'));
}