Last updated March 15, 2010. Created by Arshad Chummun on January 13, 2010.
Edited by VM. Log in to edit this page.
Step 1 : Enable the trigger module if you haven't done so. (To enable the trigger module, go to administer->site building->module. check the trigger module and press save.)
Step 2 : Go the administration panel and click on action. Under Make a new advanced action available, select Redirect to URL... and hit create.
Enter a description and the url to redirect to. You can use internal url like node/123 to redirect the user on login.
Press Save.
Step 3 : Go to the administration panel and click on triggers under site building. Select users in the tab.
Under Trigger: After a user has logged in, select the trigger you have just created and hit assign.
Logout and log back in to test.
Comments
user specific redirects
Is there a way do redirect users based on roles? Like Auth user #1, Auth user #2, etc... to be sent to different pages?
You can try this module ->
You can try this module -> http://drupal.org/project/login_destination
Arshad Chummun
Mauritius Drupal Developer
Drupal Mauritius | preprocess.me | @preprocessme
Redirect After Login custom solution
This is a very simplen but functional approach. (dirty)
Drupal always redirects to the user page (by default) ,so you can do this.
Customize User Page using Panels and the Page modules by adding a custom php block where you place a drupal_goto().
Then create your custom user page.
You can create a switcher using GET arguments in order to redirect especifically where you want.
Using access rules (within panels module on custom user variation) you can specify wich role or condition will be needed to perform the custom redirect.
Nice approach. Dirty or not:
Nice approach. Dirty or not: I used it and it does what it needs to do. Thanks for sharing.
You've made the impossible possible!
That's overstating it a bit but using your method in a different context has allowed me to do something I spent ages on not coming up with a solution.
Thanks!
Hi, I just tried and it did
Hi,
I just tried and it did not work for me. I went through every step of the description given above and I was not re-directed to a custom URL I wanted to. Is there something wrong with what I've done?
Thanks
T
Visit our Startups group on Drupal
Same here... seems like it
Same here... seems like it should work, but it doesn't.
No joy
I couldn't get it to work either; after logging in, I wanted the user to be redirected to his profile page. For my action, I selected "Redirect to a tokenized URL". Here are two URL's I tried for the user's destination:
[account-url]user/[uid]On my site's home page, the user is presented with a login form. After the form is submitted, the user is presented the same home page for the site instead of being redirected to his personal home page.
Joy, or something kind of like Joy
As it turns out, I have had success redirecting the user to a specified page following the log in action only if the user logs in via the main login page ( user/login ). When you go to this page, the default URL is something like user/login?destination=node. You can apply a Trigger or Rule to the login action and change what the destination is. However this does not work if the person logs in via a login panel or block that's part of some other page, say the home page.
Thanks
Its really good information
Thanks
I can suggest this solution
I can suggest this solution http://www.allexx.info/drupal_login_redirect It is in Russian, but you can look at the code. In two words the problem is in drupal_goto() function. Redirect works when you login from q=user page, but doesn't work when you login form block.
Not hard to believe..!
And they put this obviously untested module in the "Tutorials" section?
That tells a lot about Drupal and the Drupal documentation.
Nothing ever works the first time. You really have to be an expert at PHP and CSS to be able to fix all the bugs. But they never said anything about Russian!!?
Here is an example for you: In the Profile module page here is an extract of the instructions on the module set up:
"■ Using Content Profile Module: If you are using Content Profile you much select Show a secondary tab below the user's edit tab under Profile edit tab in the content profile content type tab per content type."
I guess there will always be another language one has to learn!
No wonder it is so frustrating...
I have been working on my Drupal site for over two month now and I haven't made any progress to speak of. I am always bogged down by bugs and bad documentation. Too much time spent looking for things. This is going to go on forever...
Time for me to wake up and move on to another CMS.
I tried it, but doesnt worked
I tried it, but doesnt worked for me. One the user logged in it doesnt redirect.
"■ Using Content Profile Module: If you are using Content Profile you much select Show a secondary tab below the user's edit tab under Profile edit tab in the content profile content type tab per content type."
Ya I really find drupal bit confusing.
Another way to redirect after
Another way to redirect after login is to use $_REQUEST['destination']. For example, to redirect the user to her profile:
$_REQUEST['destination'] = 'user';I'm using this on a custom login block and it works just fine.
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind. -- Dr. Seuss
join www.lexxing.com ! where people and languages meet
Hi. Sorry for the trouble,
Hi. Sorry for the trouble, but im really new in this Drupal thing.
Where do I exactly put that code?
Im using a custom login block just like you.
I've tried lots of ways but they only work if the user is at /user/login...
EDIT: I came up with the idea of calling the login module in my page-front since my homepage will be only the login. So, after (even) more research i found this http://data.agaric.com/node/2382 , edited
<?phpprint drupal_get_form('user_register');
?>
to
<?phpprint drupal_get_form('user_login');
?>
and all the options I've tried before worked, since the login isn't in a block anymore.
Maybe this is common knowledge but I decided to share since lots of you have helped me.
Thanks !
Use a module
Redirect from /user/login to previous page:
function mymodule_form_alter(&$form, $form_state, $form_id) {if( (arg(0)=='user') && (arg(1)=='login') && (!arg(2)) && ($form_id=='user_login') ){ // redirect from login page to previous page
if($_SERVER['HTTP_X_FORWARDED_PROTO']){
$serverstarturl = "https://";
}
else{
$serverstarturl = "http://";
}
if( strpos( $_SERVER['HTTP_REFERER'] , $serverstarturl . $_SERVER['SERVER_NAME'] ) === 0){
if($_SERVER['HTTP_REFERER'] != ($serverstarturl.$_SERVER['SERVER_NAME'].'/user/login') ){
$action=str_replace( ($serverstarturl.$_SERVER['SERVER_NAME'].'/') , '', $_SERVER['HTTP_REFERER'] );
$protocols=array('http', 'https', 'ftp', 'ftps', 'sftp', 'ssh');
$action = str_replace($protocols, '', $action); // stop people hacking action to redirect to other websites
if($action==''){
$action='home';
}
$form['#action']='/user/login?destination=' . $action;
}
}
else{
// do nothing http_referrer has been hacked, or user has come to login page from another site...
}
}
}
Senior Drupal Web Developer
Wellcome Trust Sanger Institute
This solution breaks login
This solution breaks login via Services API ( http://drupal.org/project/services )
I used XML-RPC to manage content on my Drupal website, and found that XML-RPC service is broken after this solution was used.
Just a small note for those who plan to use this approach for Drupal with Services module.
Joseph Chereshnovsky
Found the solution for this
found the user redirect solution without any Triggers and Actions
Just implement hook_user() in custom module and assign
<?php$_REQUEST['destination'] = '<front>' ;
?>
Look at the following article for details
http://www.givegoodweb.com/post/121/drupal-redirecting-a-user-after-login
Joseph Chereshnovsky