tomdchi Posted June 16, 2011 Share Posted June 16, 2011 Is it possible to execute a action hook from within another action hook? Example would be if I needed to use the InvoiceCreationPreEmail hook but only during cron run where I would use the DailyCronJob hook. Or is there any other way to have the InvoiceCreationPreEmail hook only execute during cron run? 0 Quote Link to comment Share on other sites More sharing options...
RJay45 Posted June 16, 2011 Share Posted June 16, 2011 I think all of the functions that are set as hooks are available, so couldn't you just call the function you want to run from within the cron hook function? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted June 16, 2011 Share Posted June 16, 2011 I think all of the functions that are set as hooks are available, so couldn't you just call the function you want to run from within the cron hook function? I thought about that as well, but it all depends on what order it runs in. I kinda have a feeling it will not work like that. The best solution would likely to be to hook into the InvoiceCreationPreEmail and find a way to determine if the cron is running or not. A quick hack would be to just check to see what the time is. 0 Quote Link to comment Share on other sites More sharing options...
RJay45 Posted June 16, 2011 Share Posted June 16, 2011 I thought about that as well, but it all depends on what order it runs in. I kinda have a feeling it will not work like that. The best solution would likely to be to hook into the InvoiceCreationPreEmail and find a way to determine if the cron is running or not. A quick hack would be to just check to see what the time is. Well perhaps. It is easily tested with a few debug statements and the use of PHP's get_defined_functions(). Failing any of that, perhaps you could just use an include_once statement to ensure the correct hook file is included and then call the function. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.