这个wp_mail()
在cron函数中计划时,函数未运行。我添加了以下功能:
add_filter( \'cron_schedules\', \'isa_add_every_one_minutes\' );
function isa_add_every_one_minutes( $schedules ) {
$schedules[\'every_sixty_seconds\'] = array(
\'interval\' => 60,
\'display\' => __( \'Every 1 Minutes\', \'textdomain\' )
);
return $schedules;
}
// Schedule an action if it\'s not already scheduled
if ( ! wp_next_scheduled( \'isa_add_every_one_minutes\' ) ) {
wp_schedule_event( time(), \'every_sixty_seconds\', \'isa_add_every_one_minutes\' );
}
// Hook into that action that\'ll fire every three minutes
add_action( \'isa_add_every_one_minutes\', \'only_debug_admin\' );
function only_debug_admin(){
$message = "Test message";
wp_mail( \'email@example.com\', $message, $message );
update_option(\'default_role\',\'customer\');
}
当我通过wp-control插件手动运行cron时,我收到一封邮件,wp-mail工作正常。但是,当cron作业运行时。为了调试,我在mail函数下面添加了这一行:update_option(\'default_role\',\'customer\');
我在WordPress设置中将默认角色设置为subscriber。在cron运行时,设置会更新为“customer”,但不会收到邮件。手动运行该功能时,会收到邮件。知道为什么会这样吗?