Objective

In this tutorial we will use both rules and token modules to redirect to a specific page when a user id matches X. Where X can be any number. This tutorial is for absolute beginners. If you consider yourself an advanced user find the README.txt file that comes with the module.

Requirements

  • Drupal 6.x
  • Rules module 6.x-1.2 or more recent
  • Token module 6.x-1.12 or more recent
  • We assume that the Token sub-module Token actions is activated
  • We assume that the page you want to redirect to is already created
  • We assume that you know the user id. In this tutorial we will use the user id 5

Steps

  1. Go to admin/rules/trigger
  2. Click on Add new rule tab/link to create a new rule
  3. In Label field type in anything. In this example we type in On (uid=5) login redirect to 'page/section/example' page
  4. Under Event select User has logged in option
  5. Leave other options to their default settings
  6. Click on Save changes button
  7. On the next screen click on Add an action link
  8. Under Select an action to add: select Page redirect option
  9. Click on Next button
  10. On the next screen fill the To: field. You must type in the URL of the page you want to redirect to. Without the http://www.domain-name.com/ In this example we type in page/section/example. Leave ? and # fields empty unless you know what you're doing ;). Check the option Force redirecting to the given path, even if a destination parameter is given
  11. Click on Save button
  12. On the next screen click on Add an condition link
  13. Under Select a condition to add: select Numeric comparison option
  14. Click on Next button
  15. On the next screen in the Number 1: field type in [account:uid] token. in the Number 2: field type in 5. Where 5 is the user id. This number can be anything. Leave all other settings to their default.
  16. Click on Save button
  17. That's it you have successful created a rule to redirect a user on login if user id match 5.
  18. To test simply log-in with user id 5. You'll be redirected to the page/section/example

Comments

ipohol’s picture

I tried, but after login it still directs to homepage. Anything went wrong?

Witch’s picture

same here. wont work.

Zorkoff’s picture

It worked like a charm with all three modules enabled.