1 cron_example.module cron_example_form_cron_run_submit($form, &$form_state)

Allow user to directly execute cron, optionally forcing it.

Related topics


modules/examples/cron_example/cron_example.module, line 139
Hook implementations for the Cron Example module.


function cron_example_form_cron_run_submit($form, &$form_state) {
  if (!empty($form_state['values']['cron_reset'])) {
    state_set('cron_example_next_execution', 0);

  // We don't usually use globals in this way. This is used here only to
  // make it easy to tell if cron was run by this form.
  $GLOBALS['cron_example_show_status_message'] = TRUE;
  if (backdrop_cron_run()) {
    backdrop_set_message(t('Cron ran successfully.'));
  else {
    backdrop_set_message(t('Cron run failed.'), 'error');