Redirect after registering with Drupal

Does anyone know how to return to the "last page" after the user is presented with a login screen and you want to create a new account?

Basically the sequence:

  • User is trying to get protected content
  • Redirected to login page
  • If it logs in, it is redirected to the original page
  • If he selects "create a new account" and fills it out, he is redirected to the home page

How do we automatically redirect it to the original page (and not to the static page).

+3
source share
2 answers

. - - , URL-. :

<?php
  if (user_is_anonymous()) {
    $link = l(t('Login'), 'user/login', array('query' => drupal_get_destination()));
  }
?>

admin/settings/error-reporting, , , php node, .

, , Drupal, .

. , , . , , .

- , . , 2 : 1 , - .

LoginToboggan , .

+4

php :

<?php header("Location: " . $_SERVER['HTTP_REFERER']); ?>

. php

EDIT:

$url = $_SERVER['PHP_SELF']; // or HTTP_REFERER depending on the setup

, .

0

Source: https://habr.com/ru/post/1713413/


All Articles