can Application hook use module hook events?

Dear All,

I need to track each and every module.
to have a global customization we need to use Application logic hooks .am i right?
so is that possible to use module logic hook events such as[before_save],[after_save], etc… in application logic hook?. so that i can customize save operation once, which will have impact on all modules save operation…
please guide me on this…

your help is much appreciated.
thanks in advance

Yes, It should work.
Location will be custom/modules/logic_hooks.php.

Keep in mind few things before doing it.

  1. They will trigger in all modules, so better to keep them bind into a modules array like this

$used_modules = array();
$used_modules[] ='Leads';
  1. in application level hooks, there is only 2 acceptable parameters at hook class method, so $bean is not available, only $event and $arguments are available.

So ideally avoid application-level hooks mixing with module level hooks, until you are not looking to spent hours and bind code strictly.

Thank you ashish ,

i dont understand $used_modules=array();

where i need to implement this … please give the guidance. your help is much appreciated.

@ashish please remember to use the forum’s code tags when posting PHP, otherwise brackets will disappear. Thanks :slight_smile:

1 Like

Hi Ashish…

could you please tell me where to implement the $used_modules=array();

just after starting hook function…

function abc_hook($event,$args){
$used_modules = array();
$used_modules[] ='Leads';

return false;

This way , it will work only for Leads and Accounts , for example.

Otherwise It is going to used in whole application ie in all modules , even save changes on studio, which is definitely you will not want.

1 Like

Thank you Ashish,

i understand it now. and it works … thanks again… you saved the day…