Recently I had to redirect users to the home page, and although I can do this with the 'Rules' module, I also wanted to add something to the $_SESSION for some custom code...
After a little digging I found this: http://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_login/7
/** * Impliment hook_user_login(). */ function YOURMODULENAME_user_login(&$edit, $account) { // Your logic will set $redirection to the desired location $redirection = 'node/1'; // Unless there is already a redirection going, or the user is // trying to reset his password, we redirect to $redirection. if (empty($_GET['destination']) && !is_null($redirection) && (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset')) { $_GET['destination'] = $redirection; // } }
This was done in a module, and it didn't take much to add an admin configuration page to allows the admin team to change the redirect...
Good Work! weboide
Main Category
Secondary Categories