Friday, November 18, 2011

On login redirect to the user's account page using 'Rules' module?


Steps

  1. 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 conditions and actions that we add to this rule, will be evaluated on the event "User has logged in".
  2. 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 sets always 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 and click on "Save" button.
    That's all. Just log out and log in again - you'll be redirected... :)
    Notes
    • This tutorial is for the Rules module. Not Trigger core module. Trigger module's tutorial can be found here.
    • As an alternative to the following tutorial, one can just import the ready rule from here.

    Requirements

    • Drupal 6.x
    • Rules module

    Optional

    • Token contributed module if you want to use tokenized URL. Make sure that the Token sub-module Token actions is activated.

No comments:

Post a Comment