Skip to main content
2 of 3
added 397 characters in body; edited title
NenadP
  • 1.5k
  • 19
  • 37

How to make hook in custom module to execute only on condition

How to make contributed module hook execute only if conditions are met. Those functions seem to get automatically invoked. Environment is a custom module.

examples: 1.

if ($condition) {

   function mymodule_modulename_alter ($parameters) {
     //altering code here
   }

}
    if ($condition) {
           //if condition is met, i call the function included in this custom module
           mymodule_modulename_alter ($parameters)
      }

  function mymodule_modulename_alter ($parameters) {
         //but this function will get auto-invoked! I want it run only if $condition is met.
       }

Thanks

NenadP
  • 1.5k
  • 19
  • 37