The first short tutorial will show, how rules module can be used, to configure a simple page redirection after a user has logged in.
- This tutorial is for the
Triggermodule's tutorial can be found here.
- As an alternative to the following tutorial, one can just import the ready rule from here.
- Drupal 6.x
- Rules module
- Token contributed module if you want to use tokenized URL. Make sure that the Token sub-module
Token actionsis activated.
- Create a new rule
First we have to start a new rule. For this go into the rules admin center, click on "Triggered rules" and on the tab "Add a new rule". Select the event "User has logged in", set the label "On login redirect to account page" and click "Submit".
Now we have created a new rule, which is still empty. Every condition and action that we add to this rule, will be evaluated on the event "User has logged in".
- Create a condition
To not break one-time logins and avoid redirecting from user profile form where a user needs to provide their new password we need to set a condition on our rule.
Click "Add condition". Choose the "Text comparison" type of condition and fill in fields: set "Text" to "site:current-page:path"; "Matching text" to "user/reset" (this is the common start part of the path where users appear after clicking one-time login URL); "Comparison operation" to "starts with"; and check the "Negate" checkbox. Save this condition.
- Create the redirection action
To do so, click on the "Add an action" link, under the section "System", select the action "Page redirect" and click on "Next" button. In case you have the token module installed, the "Page redirect" action allows you to use token replacements. This allows us to place the user's id in the redirect path.
So call the action "Redirect to the users account page" and set the path
user/[account:uid]. Then activate the checkbox "Force redirecting to the given path, even if a destination parameter is given" - which is necessary, because Drupal always sets a destination parameter to the current page, if a user logs in. So, that our redirection applies, we need to activate this. Check the option, and click the "Save" button.
That's all. Just log out and log in again - you'll be redirected... :)