0

Is there a Drupal 8 hook for pre-login? I would like to redirect the login information of a user on a web server by URL.

I know there is hook_user_login(), but this one only looks called once the user is connected to the database. I would like to retrieve the step before, so the login and password information.

  • Can you use the hook_user_login hook, api.drupal.org/api/drupal/core%21modules%21user%21user.api.php/…? – Jdrupal Jul 2 at 9:46
  • @Jdrupal if I have understood correctly this function only works when the user is connected, I would like the step before. So during the login / password verification – costanti Jul 2 at 9:47
  • You mean when the user login form is submitted? Then add a custom validate callback before the core ones. – 4k4 Jul 2 at 11:19
1

You can solve this by implementing hook_form_alter, something like this;

function MY_MODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_form') {
    $form['#validate'][] = 'my_module_user_login_validate';
  }
}

function my_module_user_login_validate(&$form, $form_state) {
  //Do something...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.