Question

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.

Was it helpful?

Solution

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) {
    drupal_goto('sign-up');
  }
}

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top