plugin development - Call do_action() within WordPress cronjob

admin2025-06-03  3

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();
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748956467a315139.html

最新回复(0)