n User Login Persistent Destination in drupal | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

User Login Persistent Destination in drupal 


 * Implements hook_menu_local_tasks_alter().
function Module_local_tasks_alter(array &$data, $route_name, RefinableCacheableDependencyInterface $cacheability) {
  if ($route_name == 'user.login' || $route_name == 'user.register') {
    // Vary cache by ?destination query argument.

    // Get the 'destination' query argument from current request.
    $destination = \Drupal::request()->query->get('destination');
    if (empty($destination)) {
      // No destination set for current request - we can exit now.
    foreach ($data['tabs'] as $items) {
      foreach ($items as $item) {
        /** @var \Drupal\Core\Url $url */
        $url = $item['#link']['url'];
        $query_arguments = $url->getOption('query');
        if (is_null($query_arguments)) {
          $query_arguments = [];
        $query_arguments['destination'] = $destination;
        $url->setOption('query', $query_arguments);

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts


Page Facebook