Hello all,

Is there any way to get Drupal to forward you to the /user page if you try and visit /user/register once logged in? I don't really like the way you end up seeing 'access denied' errors.

Many Thanks

Rich

Comments

AjK’s picture

I wouldn't normally advocate hacking Core at all but sometimes when you want a quick fix...

This would normally be done in a module but if you want an "instant fix" alter index.php like this:-

Where it's got :-

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$return = menu_execute_active_handler();

Add in this code...

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if (isset($user->uid) && $user->uid > 0 && arg(0) == 'user' && arg(1) == 'register') {
    drupal_goto('user');
}

$return = menu_execute_active_handler();

Not a pretty fix by any means but it'll do what you want. Or you could create a simple module to do it, for example:-

// $Id:$

foo_menu($may_cache) {
  global $user;

  if (!$may_cache) {
    if (isset($user->uid) && $user->uid > 0 && arg(0) == 'user' && arg(1) == 'register') {
      drupal_goto('user');
    }
  }
}

does pretty much the same thing without a Core hack shown eariler.

Hope that helps

oliveyrc’s picture

many thanks for that, I've got a custom module so I've put it in that and its done the trick.

Gonna extend it slightly to include others too, /user/password for example, stored in an array and then do an in_array check on the end

Rich