function og_add_users_submit in Organic groups 5
Same name and namespace in other branches
- 5.8 og.module \og_add_users_submit()
- 5.2 og.module \og_add_users_submit()
- 5.3 og.module \og_add_users_submit()
- 5.7 og.module \og_add_users_submit()
- 6.2 og.pages.inc \og_add_users_submit()
- 6 og.module \og_add_users_submit()
File
- ./
og.module, line 920
Code
function og_add_users_submit($form_id, $form_values) {
// safest option is to do a select, filter existing members, then insert
$names = explode(',', $form_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_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.'));
}