Getting where you want to go in Drupal
The following information applies to Drupal 5.x
If you are working with a protected site, using http://drupal.org/project/login_destination module is a good way to create a logic system for routing users.
In my case, I needed people to get to where they were trying to go in the first place when logging in.
For instance, if a user visits example.com/blog, and is prompted to login first, then I want them to arrive at *exactly* example.com/blog after they successfully login.
So, http://drupal.org/project/login_destination provides this functionality.
There are 2 settings that you should configure in php snippet mode:
First is URL Destination Settings:
global $user; if (substr($_SESSION['login_redirect'],0,4) != 'user') { return $_SESSION['login_redirect']; } else { return '<front>'; }
Second is Redirect condition settings:
if ($_REQUEST['destination'] != 'login_redirect') { $_SESSION['login_redirect'] = $_REQUEST['destination'] != '' ? $_REQUEST['destination'] : $_SESSION['login_page']; } return TRUE;
It is "$_SESSION['login_redirect']" that holds the data needed to get users to their desired destination.
- Sam Rose's blog
- Login to post comments

