0

I created custom module, and the module uses the mymodule_boot function. Inside that function I wrote user_load_by_mail to check the user is exists or not. But it is not working and I am not able to access site. It throws http error 500.

  • Would it be possible to move your code to hook_init? all modules are loaded already when this hook is triggered. – schlicki Feb 9 '17 at 6:56
0

You cannot call user_load_by_mail function in hook_boot because this hook is called before the theme, modules, or most include files are loaded into memory. It happens while Drupal is still in bootstrap mode.

To get this function work you need to add this code before calling user_load_by_mail function:

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  • that's the workaround - but not a good solution. hook_boot is not meant to have the system set up fully ..., better to change the hook to hook_init or else – rémy Feb 16 '17 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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