function fbconnect_register_form_validate in Facebook Connect 5
Validate the register form.
File
- ./
fbconnect.module, line 270 - This module allows site visitors to connect and register with facebook account
Code
function fbconnect_register_form_validate($form, &$form_state) {
// Validate the username
$name = $form_state['username'];
if (user_validate_name($name)) {
form_set_error('username', user_validate_name($name));
}
else {
if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE LOWER(name) = LOWER('%s')", $name)) > 0) {
form_set_error('username', t('The name %name is already taken.', array(
'%name' => $name,
)));
}
else {
if (drupal_is_denied('user', $name)) {
form_set_error('username', t('The name %name is a reserved username.', array(
'%name' => $name,
)));
}
}
}
// Validate e-mail
$mail = $form_state['mail'];
if (user_validate_mail($mail)) {
form_set_error('mail', user_validate_mail($mail));
}
else {
if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE LOWER(mail) = LOWER('%s')", $mail)) > 0) {
form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array(
'%email' => $mail,
'@password' => url('user/password'),
)));
}
else {
if (drupal_is_denied('mail', $mail)) {
form_set_error('mail', t('The e-mail address %email has been denied access.', array(
'%email' => $mail,
)));
}
}
}
}