Skip to content

Instantly share code, notes, and snippets.

@Hotfirenet
Created September 23, 2018 08:37
Show Gist options
  • Save Hotfirenet/8a1df9588249707d02a5708f325f89d6 to your computer and use it in GitHub Desktop.
Save Hotfirenet/8a1df9588249707d02a5708f325f89d6 to your computer and use it in GitHub Desktop.
Test cron wordpress
<?php
/*
Plugin Name: HFN test schedule
Version: 0.0.1
Plugin URI: http://hotfirenet.com/
Description: Plugin qui test le cron
Author: Johan VIVIEN
Author URI: http://hotfirenet.com
*/
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
if ( ! wp_next_scheduled( 'hfn_crontask_hook' ) ) {
wp_schedule_event( time(), 'hourly', 'hfn_crontask_hook' );
}
add_action( 'hfn_crontask_hook', function () {
$myTime = the_time( get_option( 'date_format' ) );
update_option( 'hfn_date_last_schedule', $myTime );
wp_mail( get_option('admin_email'), 'Automatic email', 'Automatic scheduled email from WordPress.');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment