0

We have to upgrade Drupal 8.9 to Drupal 9.3.3; since the login_destination module stop working, and we don't know why, I've tried others modules like Anonymous Login, Redirect After Login, User Redirect but none of them seem to work.

In some sites, they commented that this redirect can be solved without modules but I don't know how.

Basically, what I am trying to do is to set the *destination" parameter in URL and let Drupal use that parameter to redirect users after they log in.

EDIT:

here is the solution:

function MODULE_user_login(AccountInterface $account) {

$response = new RedirectResponse($_GET['destination']);
$request = \Drupal::request();
// Save the session so things like messages get saved.
$request->getSession()->save();
$response->prepare($request);
// Make sure to trigger kernel events.
\Drupal::service('kernel')->terminate($request, $response);
$response->send();

}

we put this code in some other module (not login destination) and works fine ...

Thanks everybody

4
  • 1
    You need to format the link URL like this, https://mywebsite.com/user/login?destination=/some-path and it will redirect the user after login in to /some-path
    – No Sssweat
    Jun 22, 2022 at 21:47
  • 1
    It would help us if you were to hyperlink your research references.
    – cilefen
    Jun 22, 2022 at 21:48
  • Yes, it is format like this. But when you login it redirects you to the front page instead Jun 23, 2022 at 6:10
  • Those modules all work. I use them, especially redirect after login but it needs a patch for 9.3. drupal.org/project/redirect_after_login/issues/3214949
    – Kevin
    Jun 23, 2022 at 10:30

0

Your Answer

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

Browse other questions tagged or ask your own question.