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.

有帮助吗?

解决方案

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...
}
许可以下: CC-BY-SA归因
scroll top