I want to set some fields in database when user registers or login. I know I don't have to change the drupal core and I guess I should use hooks for this purpose but I don't know how and where.

Should I write a new module and implement a hook inside it? What hook?


1 Answer 1


In drupal 6, there is a function named hook_user.

By using this hook in your custom module. You can do watever you want. Remember to put condition in this by '$op' like

function hook_user($op, &$edit, &$account, $category = NULL) {
  if($op == 'login') {
    //do watever you want

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.