Tutorial 1: On login redirect to the user's account page
The first short tutorial will show, how rules can be used, to configure a simple page redirection after a user has logged in.
As an alternative, one can just import the ready rule from here.
Requirements
- Drupal 6.x
- Trigger core module must be activated under
admin/build/modules
Optional
- Token contributed module if you want to use tokenized URL. Make sure that the Token sub-module
Token actionsis activated.
Steps
-
We are now going to create an action. To do so go to Actions settings page under
admin/settings/actions
Scroll down the page to find the sectionMake a new advanced action available.
Click onChoose an advanced actiondrop down menu.
ChooseRedirect to URL.... Note that if you want to use a tokenized URL then chooseRedirect to a tokenized URL...
Click onCreatebutton.A new window opens
Configure an advanced action
UnderDescription:you should readRedirect to URL. This is optional but to better identify the precise action taking place you should change theDescriptionfield. This description will be displayed in modules such as the trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Redirect to the user's account page" rather than simply "Redirect to URL").
UnderURL:type in the URL you want the user to be redirect to after logging in. In my case for this tutorial I want the user to be redirected to the user's account page so I type inuser
MoreURL:examples<front>will redirect user to your site default front page. As defined underadmin/settings/site-information.user/[user-id]/trackwill redirect user to user'sTrackpage. To read more about tokenized actions expend thePlaceholder tokenssection located at the bottom ofConfigure an advanced actionpage. Note that you must install Token contributed module if you want to use tokenized URL. Plus you must activate the Token sub-moduleToken actions.
Click on
Submitbutton.
You have successfully created an action. You now have a new line added toActions available to Drupal:section. -
We are now going to create a trigger. To do so go to
admin/build/trigger
Click on appropriate tab located at the top of this page. In this tutorial I click onUserstab.
Scroll down the page to findTrigger: After a user has logged in.
Click onChoose an actiondrop down menu.
ChooseRedirect to URLaction or choose the name you gave to your action.
Click onAssignbutton.
You have successfully created a trigger. Your action is now display underTrigger: After a user has logged in > Name.
That's all. To test log-out and log-in. You'll be redirected.

note the token requirement!
FYI following this tutorial, you'll log in and get a page not found error if you don't install the token module. The url trailer might end "/user/[account%3Auid]" upon logging in without enabling that module.
Redirect to front page
I tried to use this tutorial to change the login redirection from the user account (default in my Drupal installation) to the front page.
This tutorial din't work for me at all. As with so many instructions here the people writing them never take the time to put the correct terms and links in to make life easy and to avoid confusion.
Anyway, may be this tutorial works and I am on the wrong "garden path". In any case this is what I did to get users on login to the front page.
1. ..../admin/settings/actions (Actions settings page)
Go to the bottom and open the drop down menu to the left of [create] and choose Redirect to URL press [create].
2. A new window opens - "Configure an advanced action"
Here you should read -
Description:
Redirect to URL
In the line below add the page link where your users should arrive at after logging in. In my case I choose
<front>.URL:
<front>Press [Save] and now you should have a new line added to "Actions available to Drupal:"
system ....... Redirect to URL ..... configure .... delete
3. Next step - go to Triggers. You can click on it above in the explanation text or use ..../admin/build/trigger/node.
Now choose the user tab or .../admin/build/trigger/user.
Go down to Trigger: After a user has logged in.
From the drop down box choose "Redirect to URL" and press [Assign].
Done!!! [I hope ;-) ]
If you are redirecting to another page you might need to experiment with the link code along the lines of .../content/user-start-here-page.
Good luck
This really works thanks! I
This really works thanks!
I had no luck with rules redirecting to frontpage but the action and trigger combo really solve it.
Enable the Trigger Module..
I know that this is probably idiotic, but it took me too long to realize that I had to enable the Trigger Module. I thought I would drop a note here to save other people like me 20 minutes.
idiotic but useful, this
idiotic but useful, this simple tip saved me a lot of headaches. Thanks!!
Thanks you.
Thanks you.
Thanks snohio
Thanks for your comment snohio. I have updated the tutorial by adding a 'Requirements' section.
---
How to contribute to Drupal.
It works ..... but I have a question
Your comment saved my day today. Great thanks! :-)
BUT... I have two sub-sites - each of them I would like to redirect to its own front page after logging in. With one sub-site your procedure works smoothly, but the second sub-site is always redirected to /admin.
Moreover I cannot force neither of them to redirect to any other URL (e.g. http://drupal.org, or node/2, or ... ... ... ...). It seems that there is only one direction for each sub-site (somewhere written) and nothing can chage it.
Is there any problem with my configuration? I am quite new in Drupal world... Maybe any module I need to install or switch on.
I appreciate any help.
For redirecting to the front
For redirecting to the front page just follow the tutorial at the top of the page and leave the redirect field empty. Explanation, since the redirect is relative to the sites Base URL (domain) leaving the redirect field empty will redirect to the base url. Anything placed in the redirect field will just be appended to the base URL.
Thanks tryitonce
Thanks tryitonce. I re-wrote the tutorial base on you comment.
---
How to contribute to Drupal.
wrong module
Hi Onopoc,
The original tutorial worked for me using the Rules module. I suggest you place your re-write into documentation for the trigger module, NOT the rules module. I think a lot of people are confused that trigger and rules modules are alternative, distinct implementations.
trigger vs. rules module
Note that the trigger and rules modules are separate, alternative solutions to the task of "triggering actions". It appears that you were unable to get the rules tutorial to work, so you developed your own similar procedure using the trigger module.
I'm also still on the learning curve on this, but I think the rules module claims to be a more versatile and powerful alternative to the trigger module. The documentation doesn't make it completely clear, but I think one should turn off the trigger module in order to use rules.
Install latest development version of Token module
You need to install latest development version for token replacements to work. Any version after 27-AUG-2008. http://groups.drupal.org/node/10270/rules-modules
Also see FAQ here http://groups.drupal.org/node/15542
Can't get either walkthrough to work...
I know I'm a newb, but I have followed the main instructions and the one in the thread exactly and cannot get the redirect to actually work. Assuming there is no step missing in either walkthrough, has anyone else had a problem getting this to work? I'm so excited about learning and using rules, but hitting a roadblock right away, am I the only one?
EDIT
I was able to setup an exact same rule on users logging out. So my problem seems to be specific to a rule when a user logs in. Leaves me even more confused onto why... but at least I'm getting rules to work. Anyone have an explanation for this?
redirect URL NOT work but display message works???
Hi,
I set an action (redirect URL[internal or external links) to the Trigger (After a user has logged in). When a user login, it always goes to the orginal page (the page when it is logout status).
I tried to set another action (display message) to the same trigger (after a user has logged in). It shows the message.
Can anyone tells me why this URL redirect does not work?
Note: I tried both action/trigger or rules module. The results are the same.
Thanks.
hosais.
I've the same problem: the
I've the same problem: the debug message is displayed, but it shows the destination token, not the token value, and it doesn't do the redirect.