Permalink
Browse files

docs(cron): added an example how to register a cron hook handler

fixes #7774
  • Loading branch information...
jdalsem committed Apr 8, 2016
1 parent b27aee7 commit 4b54a099e7ddc5cacdf214d5ea383eddc03b255f
Showing with 31 additions and 0 deletions.
  1. +30 −0 docs/guides/cron.rst
  2. +1 −0 docs/guides/index.rst
View
@@ -0,0 +1,30 @@
Cron
====
If you setup cron correctly as described in :doc:`/admin/cron`
special hooks will be triggered so you can register for these hooks from your own code.
The example below registers a function for the daily cron.
.. code:: php
function my_plugin_init() {
elgg_register_plugin_hook_handler('cron', 'daily', 'my_plugin_cron_handler');
}
If timing is important in your cron hook be advised that the functions
are executed in order of registration. This could mean that your function may
start (a lot) later then you may have expected. However the parameters provided
in the hook contain the original starting time of the cron, so you can always use that
information.
.. code:: php
function my_plugin_cron_handler($hook, $period, $return, $params) {
$start_time = elgg_extract('time', $params);
}
.. seealso::
:doc:`/design/events` has more information about hooks
View
@@ -13,6 +13,7 @@ Customize Elgg's behavior with plugins.
ajax
authentication
context
cron
database
actions
helpers

0 comments on commit 4b54a09

Please sign in to comment.