Hook_user not called for login operation

I read in the drupal documentation that hook_user should be called for a login operation. To test this, I added a call drupal_set_messageat the top of my hook implementation, and the only message I get is a call with 'load' like $ op.

I have confirmed that drupal_set_message can be called multiple times and does not delete the previous message, so I am sure that hook_user is called only once.

Any good reasons why hook_user does not start with 'login' as the login operation?

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

function favequest_favorites_user($op, &$edit, &$user, $caterogy=NULL) {
  drupal_set_message($op);
}
+3
source share
3 answers

As often happens, I tracked this down to the interaction of the modules.

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

It is freed before all other modules can be able to execute.

+2
source

You have a typo with the spelling of the variable "$ caterogy", but that does not matter, since you are not using it in this test:

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

Using your code, I get four messages when I log in:

  • load
  • load
  • To come in
  • load

How to change user account? Do you get a “view” of $ op on the My Account page and $ op form when editing it?

, "logout" $op - , - , .

+1

See if you have drupal_goto after logging in. http://drupal.org/node/228688

About drupal_set_message - Messages are saved in the session. When you log in, the session gets reset, and this may be the reason that you do not see them. For quick debugging, I recommend using the devel module with dd or syslog functions.

Adi

0
source

Source: https://habr.com/ru/post/1741546/


All Articles