0

For example in the user module there is a hook_user_login hook

When a user logs in in function user_login_finalize() will be called, then user_login_finalize will call user_module_invoke('login', $edit, $user); that will call system_user_login (and others module's function[moudulename_user_login] that implements hook_user_login());

I am puzzled at which function will call hook_user_login() and when it will be Invoked. What is the role of this function?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Go to the docs page for the hook you want info on, click on the collapsed "x invocation(s) of hook_name()" and you'll see what functions invoke it. The docs page will explain what the hook is for, if you're struggling with English ask someone with more experience in it to help you; we can't help you with translation issues here for obvious reasons – Clive Sep 16 '13 at 12:43

1 Answers1

0

As you mentioned, the user_login_finalize will call user_module_invoke('login', $edit, $user).

The user_module_invoke function will then look at the first argument of the function (login) and based on that value it will call the hook_user_login() function.

The main goal for a module to implement the hook_user_login() function is to be notified that a user just logged in, so it can take additional actions: add additional information to the database, write a special message to the screen if it is the user his/her birthday, etc ...

twom
  • 1
  • 1
  • http://stackoverflow.com/questions/4999138/drupal-are-hook-functions-in-api-php-ever-called i found a similar question and the answer say the hood_xxx() function just documentation files that describe hooks by modules. i am puzzled now. – Wuyue Oo Sep 17 '13 at 01:52