phunguyen19
10/17/2017 - 10:32 AM

Drupal redirect after login

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()
    );
  }
}