0

Now i know there are some ways that a redirect on login can be setup, ie using views etc, but i think my issue maybe a bit more complicated.

When a user accesses a node for example where they are prompted to login, from here they are directed over to the /user/login page.

I want the user to be redirected back to the page they were before they came to the /user/login page, with a few exceptions of course.

How can i get the user journey to be...Node -> user/login -> redirect back to Node?

1

One of the ways to do this (if you are able to build the links manually) is to add the destination parameter to the URL.

/user/login?destination=node/xxxx

After login, you will automatically be redirected to node/xxxx.

| improve this answer | |
  • I think you are along the right lines here, the only problem is my /user/login pages are setup using FPP and so cannot use a token for each referring node. – Key Apr 8 '15 at 15:05
1

Here's another way with Rules:

Event - Drupal initialize

Condition - site current user does not have a role authenticated Condition - site current page url does not contain 'user/'

Action - Site-redirect to user/login, append original destination.

Not the most efficient of ways, but no coding is required.

| improve this answer | |
  • Tried setting this up but have realised this is not what i am after, this forces anonymous using to the login page. – Key Apr 8 '15 at 15:05
1

There is a module that takes care of this called Login Destination.

The Login Destination module allows you to customize the destination that a user is redirected to after logging in, registering to the site (7.x), using a one-time login link or logging out (7.x). The destination can be an internal page or an external URL. It is possible to specify certain conditions like referring pages or user roles and make the destination depend upon them. You may use PHP snippets to provide custom conditions and destinations. It is also possible to keep users on the currently visited page after logging in or out.

Also available for Drupal 8Login Destination (D8)

| improve this answer | |
  • Have tried this module but doesn't seem like it works to what i need it for – Key Apr 8 '15 at 15:03
  • @Key I'm not sure how you are redirecting users to the login page in the first place, but you can probably replace that process with r4032login which will take care of both redirects. – Patrick Ryan Apr 8 '15 at 15:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.