0

I have an action that calls a function which takes about 20 seconds to complete (uploading file to remote server). How can I code it in such a way so that it could check if WP cron is running the same action?

I'm trying to prevent double run.

2
  • 1
    You might want something like a lock. Could be a single option field, that you set to true BEFORE you start the long-lasting action and to false after you finish / certain time, where you expect to be a timeout have happened.
    – kero
    Sep 22, 2022 at 14:18
  • I found doing_action (developer.wordpress.org/reference/functions/doing_action) but when I use it, it doesn't seem to run my code. I'm doing a simple call like if ( !doing_action( 'my_upload' ) ) { //Run code }
    – ratib90486
    Sep 22, 2022 at 22:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.