I created a module in order to define a few functions that I would like to use from a workflow rule. The workflow rule is triggered by an event and runs a php code snippet. The php snippet that it runs is simply a function call to the function that I defined in my module.

However each time my rule executes the code, I see an error in the httpd error_log - call to undefined function. I ran the module through php lint, and I enabled it, flushed caches, and even restarted httpd for good measure. Still I get the error "PHP Fatal error: Call to undefined function" in the log.

I'm new to modules and Drupal programming so I must be missing something, but I thought functions defined in drupal modules (modulename.module) are global?

BTW I followed the instructions here.

Edit1: I defined my functions in module.module (not .inc...)

  • 1
    Have you checked that the module is enabled?
    – Wtower
    Feb 12, 2014 at 15:55
  • defined in my module - in .module or in .inc? (of course it only matters if it's enabled)
    – Mołot
    Feb 12, 2014 at 15:59
  • did you flush cache?
    – jdu
    Feb 12, 2014 at 16:08
  • Yes it's enabled - I actually stated that in the question :)
    – Brad Hein
    Feb 12, 2014 at 16:26
  • @jdu yes I flushed cache - also mentioned in my question
    – Brad Hein
    Feb 12, 2014 at 16:27

1 Answer 1


I usually define my modules functions in a separate .inc file, and when i need them somewhere (usually sub-modules) i first include them with module_load_include( file-extension, module-name, file-path)

You can add the module_load_include() call at top of your snippet, or, if you need those function in many other places in your module hook_init() and make it avaible to every page.

  • I like this solution - I'd rather include the functions, run the function, and let them go out of scope and free up those resources. is it OK to have a blank .module and put all my functions in .inc then?
    – Brad Hein
    Feb 12, 2014 at 16:31
  • I think it worked! I move all functions from my .module into a new functions.inc and used module_load_include to pull in the .inc file and get to my functions. Thank you!
    – Brad Hein
    Feb 12, 2014 at 16:36
  • Yes you can use a completely empty file for .module (it must exist though).
    – AKS
    Feb 12, 2014 at 16:37
  • You can keep those function inside the .module file too, i have them in a dedicated file for the sake of order
    – Astrayus
    Feb 12, 2014 at 16:45
  • @astrayus odd thing is when they were in the .module, I get call to undefined function, however when I moved them to the inc, used module_load_include .inc and then call the function, it worked like a charm.
    – Brad Hein
    Feb 12, 2014 at 18:28

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.