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);
}
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.
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.
See if you have a drupal_goto after you login. http://drupal.org/node/228688
About drupal_set_message - The messages are saved into the session. When you login the session gets reset, and that might be the reason you don't see them. For a quick debug I recommend using devel module with dd function or system log messages.
Adi
精彩评论