After logging in, redirecting to the input URL?

The site I'm working on uses the Frontpage module to redirect anonymous users to the login page. And I know about using triggers to configure the action for redirection after login (set for one specific URL). But here's the catch:

My users come to a different login URL, for example: www.mysite / PersonsName

Is there a way to redirect back to the input URL after login?

+3
source share
3 answers

No need to encode: this is done with various available settings to the existing login_destination .

+3
source

, hook_user().

function yourmodule_user($op, &$edit, &$account, $category = null)
{
  switch ($op) {
    case 'login':
      $_REQUEST['destination'] = $_REQUEST['q'];
    break;
  }
}

$_REQUEST ['destination'] ( , login_destination)

+2

You can take the url and explode "/" like this:

$url =  explode("/",$_SERVER['REQUEST_URI']);

Then configure the session to save the username that he has accessed as follows:

$_SESSION['used_name'] = $url[0];

And you can configure the page to which it is redirected after a successful login, for example:

$success_page = "yourpage/".$_SESSION['used_name'];

Hope this is what you were looking for.

0
source

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


All Articles