function signup_validate_anon_email in Signup 6.2
Same name and namespace in other branches
- 5.2 signup.module \signup_validate_anon_email()
- 5 signup.module \signup_validate_anon_email()
- 6 includes/signup_form.inc \signup_validate_anon_email()
- 7 includes/signup_form.inc \signup_validate_anon_email()
Validate the email address for an anonymous signup.
Parameters
$nid: The node the user is signing up for.
$anon_mail: The anonymous email address to validate.
$name: The form element being validated (optional).
Return value
Boolean. TRUE if the address validates, FALSE otherwise.
1 call to signup_validate_anon_email()
- signup_form_validate_anon in includes/
signup_form.inc - Validate handler for the email address on the anonymous user signup form.
File
- includes/
signup_form.inc, line 153 - Code for the form when users sign up.
Code
function signup_validate_anon_email($nid, $anon_mail, $name = FALSE) {
if (!valid_email_address($anon_mail)) {
$message = t('Invalid email address entered for signup.');
}
elseif (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE mail = '%s'", $anon_mail))) {
$message = t('The email address entered belongs to a registered user.');
}
elseif (db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE anon_mail = '%s' AND nid = %d", $anon_mail, $nid))) {
$node = node_load($nid);
$message = t('The email address entered has already been used to sign up for this %node_type.', array(
'%node_type' => node_get_types('name', $node->type),
));
}
// If there's no message, it's a valid email, so return success.
if (!isset($message)) {
return TRUE;
}
// Depending on how we were called, propagate the error accordinly.
if ($name) {
form_set_error($name, $message);
}
else {
drupal_set_message($message, 'error');
}
return FALSE;
}