You are here

function logintoboggan_user_login_validate in LoginToboggan 8

Same name and namespace in other branches
  1. 5 logintoboggan.module \logintoboggan_user_login_validate()
  2. 6 logintoboggan.module \logintoboggan_user_login_validate()
  3. 7 logintoboggan.module \logintoboggan_user_login_validate()

Custom validation for user login form.

1 string reference to 'logintoboggan_user_login_validate'
logintoboggan_form_alter in ./logintoboggan.module
Implements hook_form_alter().

File

./logintoboggan.module, line 258
LoginToboggan module.

Code

function logintoboggan_user_login_validate($form, &$form_state) {
  if ($form_state
    ->hasValue('name')) {
    $name = $form_state
      ->getValue('name');
    $connection = Database::getConnection();
    $result = $connection
      ->select('users_field_data', 'ufd')
      ->fields('ufd', [
      'name',
    ])
      ->condition('mail', $name, 'like')
      ->execute()
      ->fetchfield();
    if ($result) {
      $form_state
        ->setValue('name', $result);
    }
  }
}