loop – Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron

Question

I’m working on calling my function from server cron instead of using WP Cron. The problem I occured is simple. When I add $args to wp_schedule_event() method, and check for the successfull addition in plugin called WPCrontrol, i see that on every page refresh the same hook is added over and over again.

I have a function called generateXlsxFile() to whom I need to pass one variable boolean(true).

Steps I tried so far:

1) if (!wp_next_scheduled('generateXlsxFile')){ wp_schedule_event(time(), 'daily', 'generateXlsxFile', array(true); }
2)add_action('generateXlsxFile', 'generateXlsxFile', 10 , 1);

If I don’t use array(true) in wp_schedule_event(), everything works as intended. If I addarray(true), it starts looping on adding hook over and over again. I have no idea what is causing this, because without arguments another wp_schedule_event() method is working fine.

Any lead would be appreciated. Thanks!

0
Artis S 3 weeks 2021-05-26T07:06:35-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse