Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, I'm trying to run some PHP as an action. I am a little fuzzy about what Drupal API call I can make there. I am trying to invoke functions from another module. So I was thinking I need to load that module first, like:
module_load_include('module', 'commerce_payment');
module_load_include('module', 'commerce_moodle');
Is this the right way? Or are all Drupal modules already loaded, present? I will be trying to pass some parameters into these functions, hopefully.
Thanks for guidance.
Comments
Comment #2
TR CreditAttribution: TR commentedEnabled .module files are automatically loaded by Drupal when Drupal bootstraps, but .inc files are only loaded when demanded. So yes, use module_load_include() if the function you're trying to call isn't found. Generally, however, functions that are part of a module's API should be in the .module file.