2

I'm using the following code to redirect users at login (Drupal 6):

function hook_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
    case 'login':
        if (_cns_user($account)) {
            unset($_GET['destination']);
            unset($_REQUEST['destination']);
            drupal_goto('user/'. $account->uid .'/training', NULL, 'steps');
        }
        break;
    }
}

The problem I have is that this doesn't allow for users to be redirected to the password reset page (user/reset/) when needed. Is there a way to prevent the reset url from being redirected? Thanks in advance.

1

The simplest way would probably be to just test for the path, which you can get access to via arg(). Something like this would do the trick:

function hook_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'login':
      if (_cns_user($account) && !(arg(0) == 'user' && arg(1) == 'reset')) {
        unset($_GET['destination']);
        unset($_REQUEST['destination']);
        drupal_goto('user/'. $account->uid .'/training', NULL, 'steps');
      }
      break;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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