You are here

function _multiple_email_user_register_form_validate in Multiple E-mail Addresses 2.x

Same name and namespace in other branches
  1. 7 multiple_email.module \_multiple_email_user_register_form_validate()

Custom validator for the user registration form.

Check if the typed mail is already in use by another user.

1 string reference to '_multiple_email_user_register_form_validate'
multiple_email_form_user_register_form_alter in ./multiple_email.module
Implements hook_form_BASE_FORM_ID_alter().

File

./multiple_email.module, line 202
multiple_email module file

Code

function _multiple_email_user_register_form_validate($element, &$form_state, $form) {
  $mail = $element['#value'];
  if (!empty($mail)) {
    $email = multiple_email_find_address($mail);

    // If this is an email
    if (!empty($email) && empty($email->primary_address) && (empty($account->uid) || $account->uid != $email->uid)) {
      form_error($element, 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'),
      )));
    }
  }
}