This is a practically copy/pasted version of the hourly wp_schedule_event example taken from the .org site. Its not moving…and I know I have visitors to “trigger” it. Its kind of a pain to wait an hour to see if it goes or not.
Can someone tell me where I’m going wrong? The only thing I can think is that I’m running it in a theme, and maybe it only works in a plugin setting? I’m lost.
//set up hourly fetching of symbiocards
register_activation_hook( __FILE__, 'symbiostock_chron_activation' );
add_action( 'symbiostock_twicedaily_symbiocard_update', 'update_symbiocards' );
function symbiocards_activation() {
if ( !wp_next_scheduled( 'symbiocards_hourly_event' ) ) {
wp_schedule_event( time(), 'hourly', 'symbiocards_hourly_event');
}
}
add_action('wp', 'symbiocards_activation');
function update_symbiocards() {
$update = new network_manager();
$sites = $update->get_connected_networks();
foreach ( $sites as $site ) {
$update->fetch_symbiocard( $site[ 'address' ] );
} //$sites as $site
symbiostock_save_network_info();
update_option('symbiocards_last_update', current_time( 'mysql' ));
wp_mail( get_bloginfo( 'admin_email' ), '[symbiostock_network_update] Network Symbiocards Updated - ' . current_time( 'mysql' ), 'Network Symbiocards Updated - ' . current_time( 'mysql' ) );
}
In your code example you have:
but there is no
symbiocards_hourly_event
hook defined.If you are using it in the
functions.php
file in your current theme directory, then please try this snippet instead:where you should convince yourself that the
wp_mail()
part is working and is using the correct email address.There are many good cron manager plugins out there that you can use to debug your problem. Here is for example a view from the FFF Cron Manager: