admin管理员组文章数量:1130349
I am using this code in my functions.php which works fine. However, I was wondering if this is the best practice to do so to schedule an event, or if there is a better solution.
if (!wp_next_scheduled('my_task_hook')) {
wp_schedule_event( time(), 'daily', 'my_task_hook' );
}
add_action( 'my_task_hook', 'my_task_function' );
function my_task_function() {
wp_mail('[email protected]', 'Test Email', 'Hello, this is a test automatically scheduled email from WordPress.');
}
I am using this code in my functions.php which works fine. However, I was wondering if this is the best practice to do so to schedule an event, or if there is a better solution.
if (!wp_next_scheduled('my_task_hook')) {
wp_schedule_event( time(), 'daily', 'my_task_hook' );
}
add_action( 'my_task_hook', 'my_task_function' );
function my_task_function() {
wp_mail('[email protected]', 'Test Email', 'Hello, this is a test automatically scheduled email from WordPress.');
}
本文标签: eventsWpscheduleevent functionsphp
版权声明:本文标题:events - Wp_schedule_event functions.php 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749241245a2338128.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论