function signup_form_validate_username in Signup 7
Same name and namespace in other branches
- 5.2 signup.module \signup_form_validate_username()
- 6.2 includes/signup_form.inc \signup_form_validate_username()
- 6 includes/signup_form.inc \signup_form_validate_username()
Validates the username on the admin form to signup another user.
Parameters
array $form: Form array for the username field.
array $form_state: The form state array containing node ID of the node the user is being signed up for.
1 string reference to 'signup_form_validate_username'
- signup_form in includes/
signup_form.inc - Build the user signup form.
File
- includes/
signup_form.inc, line 186 - Code for the form when users sign up.
Code
function signup_form_validate_username($form, $form_state) {
$nid = $form_state['values']['nid'];
$username = $form_state['values']['signup_username'];
$accounts = user_load_multiple(array(), array(
'name' => $username,
));
foreach ($accounts as $account) {
if (empty($account)) {
form_set_error('signup_username', t('User %user_name does not exist.', array(
'%user_name' => $username,
)));
}
elseif ((bool) db_query_range("SELECT 1 FROM {signup_log} WHERE uid = :uid AND nid = :nid", 0, 1, array(
':uid' => $account->uid,
':nid' => $nid,
))
->fetchField() > 0) {
$node = node_load($nid);
form_set_error('signup_username', t('User !user is already signed up for %title', array(
'!user' => theme('username', array(
'account' => $account,
)),
'%title' => $node->title,
)));
}
}
}