You are here

function user_email_verification_request_validate in User email verification 7

_state

Parameters

unknown $form:

File

./user_email_verification.admin.inc, line 173
Administrative functions required in a specific case.

Code

function user_email_verification_request_validate($form, &$form_state) {
  $name = trim($form_state['values']['name']);

  // Try to load by email.
  $users = user_load_multiple(array(), array(
    'mail' => $name,
    'status' => '1',
  ));
  $account = reset($users);
  if (!$account) {

    // No success, try to load by name.
    $users = user_load_multiple(array(), array(
      'name' => $name,
      'status' => '1',
    ));
    $account = reset($users);
  }
  if (isset($account->uid)) {
    form_set_value(array(
      '#parents' => array(
        'account',
      ),
    ), $account, $form_state);
  }
  else {
    form_set_error('name', t('Sorry, %name is not recognized as a user name or an e-mail address.', array(
      '%name' => $name,
    )));
  }
}