$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugin development - Call do_action() within WordPress cronjob|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugin development - Call do_action() within WordPress cronjob

matteradmin9PV0评论

I've programmed a cronjob in WordPress which get's executed every 5 minutes. In the function of the cronjob im trying to perform a do_action:

error_log('Send Email');
do_action( 'trigger_new_subscription_notification_email', $dv_id, $new_order->id );

My problem is now that I can see the error_log in the debug.log of WordPress but there is no email sent. When I trigger the cronjob manually like in a cronmanager, I receive the email.

I've also disabled wp_cron and implemented a real cron call via a linux script.

So is it not possible to do a do_action within WordPress cronjob?

I've programmed a cronjob in WordPress which get's executed every 5 minutes. In the function of the cronjob im trying to perform a do_action:

error_log('Send Email');
do_action( 'trigger_new_subscription_notification_email', $dv_id, $new_order->id );

My problem is now that I can see the error_log in the debug.log of WordPress but there is no email sent. When I trigger the cronjob manually like in a cronmanager, I receive the email.

I've also disabled wp_cron and implemented a real cron call via a linux script.

So is it not possible to do a do_action within WordPress cronjob?

Share Improve this question asked Jan 31, 2019 at 20:26 Johnny97Johnny97 2147 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default -1

You need to add this before calling do_action:

WC()->mailer();
Post a comment

comment list (0)

  1. No comments so far