tags:

views:

94

answers:

3

I've read in the drupal documentation that hook_user should be invoked for the login operation. To test this I've added a call to drupal_set_message at the top of my modules hook implementation and the only message I'm receiving is a call with 'load' as the $op.

I've confirmed that drupal_set_message can be called multiple times and it doesn't erase the previous message, so I'm confident that hook_user is only being invoked the one time.

Any good reasons for why hook_user isn't being invoked with 'login' as an operation when I'm logging in?

Drupal version is 6 and my module is called "favequest_favorites" its implementation of hook_user (for testing purposes) is:

function favequest_favorites_user($op, &$edit, &$user, $caterogy=NULL) {
  drupal_set_message($op);
}
+1  A: 

You've got a typo with the spelling of the "$caterogy" variable, but that shouldn't matter, since you're not using it in this test:

function favequest_favorites_user($op, &$edit, &$user, $caterogy=NULL) {

Using your code, I get four messages on login:

  • load
  • load
  • login
  • load

How about if you edit the user account? Do you get the "view" $op on the My Account page, and the "form" $op when you edit it?

Interesting that I don't get the "logout" $op when I log out--I assume that has something to do with a redirect, once I'm no longer authenticated.

flamingLogos
Thank you for putting the time into trying to solve my problem. +1
Allain Lalonde
about the non logout message - it might be related to the anonymous cache.
Adi
+1  A: 

As is often the case I've tracked this down to the interaction of modules.

Do not use the "Login Destination" module if you plan on using hook_user in your modules.

It bails out before all other modules may have had a chance to execute.

Allain Lalonde
A: 

check this up http://drupal.org/node/228688

Adi