Last active
June 10, 2022 13:42
-
-
Save phunguyen19/92793a71356a5d05349cd1a7a46cf374 to your computer and use it in GitHub Desktop.
drupal redirect after login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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