我想在Wp3中安排一个cron作业。5.1向预约待定的客户发送电子邮件。
下面是我正在尝试的一些代码:
For the testing am scheduling corn for each second to insert row in table.
// insert row every second
add_action(\'wp\', \'my_activation\');
function my_activation() {
if ( !wp_next_scheduled( \'my_event\' ) ) {
wp_schedule_event( time(), \'hourly\', \'my_event\');
}
}
add_action(\'my_event\', \'do_this_event\');
function do_this_event() {
global $wpdb;
$wpdb->query("INSERT INTO `wordpress-testing`.`wp_test` (`id`, `text`) VALUES (NULL, \'b\');");
}
wp_get_schedules(\'my_event\');
//custom recurrence
add_filter( \'cron_schedules\', \'cron_add_every_sec\' );
function cron_add_every_sec( $schedules ) {
$schedules[\'hourly\'] = array(
\'interval\' => 1,
\'display\' => __( \'Do Secondly\' )
);
return $schedules;
}
这样做可能会出错。所以请帮我度过难关。Is cron run automatically after activation once OR its need to recurring visit after scheduled time past?