Skip to content

Instantly share code, notes, and snippets.

@phunguyen19
Last active June 10, 2022 13:42
Show Gist options
  • Save phunguyen19/92793a71356a5d05349cd1a7a46cf374 to your computer and use it in GitHub Desktop.
Save phunguyen19/92793a71356a5d05349cd1a7a46cf374 to your computer and use it in GitHub Desktop.
drupal redirect after login
<?php
/**
* Implements hook_user_login().
*/
function mymodule_user_login(\Drupal\user\UserInterface $account) {
// Default login destination to the dashboard.
$current_request = \Drupal::service('request_stack')->getCurrentRequest();
if (!$current_request->query->get('destination')) {
$current_request->query->set(
'destination',
\Drupal\Core\Url::fromRoute('mymodule.route')->toString()
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment