Jump to content

Action Hook Chaining


tomdchi

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated