I'm using Drupal 6.

I want to redirect users from /user/login, /user/register, /user to /sign-up if the user is the anonymous user. This page would show both login and register forms together.

The only page left would be /user/password, which form I don't want to have on /sign-up.
I'm comfortable with PHP, but I'm not sure about which hooks should I use to achieve this.

PS. I already know how to print those forms on my own. My doubt is just about the URLs.

2 Answers 2


There is no dedicated hook for things like this, but you can implement hook_init() and then do the redirect there. Something like this:

function yourmodule_init() {
  global $user;
  if (in_array($_GET['q'], array('user', 'user/login', 'user/register') && !$user->uid) {

The easy way, you can just enable Path module, and create URL aliases for the paths you want.

Go to admin/build/path/add and create the aliases. But this will keep the same page, if you want a more custom page, and you have already the form by your own, create a hook_menu, and place the form on it.

  • Enabling path and creating a URL alias will not redirect them, so this recomendation is not useful for me.
    – Fidelix
    May 26, 2011 at 17:09
  • Can you please elaborate how I would use hook_menu to do this? Trying this: pastebin.com/uetJWxuJ does not work. Maybe the user/login path is protected?
    – Fidelix
    May 26, 2011 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.