Skip to content

Instantly share code, notes, and snippets.

@kevinchampion
Created May 23, 2012 22:11
Show Gist options
  • Save kevinchampion/2778134 to your computer and use it in GitHub Desktop.
Save kevinchampion/2778134 to your computer and use it in GitHub Desktop.
Redirecting in hook_user (Drupal 6)
/**
* Implements hook_user().
*/
function gpxhacks_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'load':
if ($account->login == 0) {
$account->redirect_after_login = 'user/' . $account->uid . '/edit';
}
else {
$account->redirect_after_login = 'dashboard';
}
break;
case 'login':
watchdog('gpxhacks', 'hook_user login redirect: @r', array('@r' => print_r($account->redirect_after_login, TRUE)), WATCHDOG_NOTICE);
watchdog('gpxhacks', 'hook_user login redirect edit: @r', array('@r' => print_r($edit, TRUE)), WATCHDOG_NOTICE);
drupal_goto($account->redirect_after_login);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment