I'm working on a membership system which is going to process renewal payments.

If I use set_time_limit(0) inside the wp_schedule_event (cron) function, is that enough to ensure that it has the time it needs to execute the payment processing? We're using Stripe, and I assume their API responses will be around 1-2 seconds per transaction (hopefully less), but if I need to process a lot of transactions I'm worried about hitting the generic 30 second timeout.

I would prefer to set this at runtime and not globally in php.ini

Code example:

//CRON - Setup rebilling
add_action('dd_cron_rebill_expiry', 'dd_rebill_expiry');
add_action('init', function() {
   //Make sure we don't schedule duplicate events if this already exists!
   if (!wp_next_scheduled('dd_cron_rebill_expiry')) {
   //Schedule hourly 
   $time = strtotime("+1 hours", strtotime(current_time('Y-m-d h:00:00'))); 
   wp_schedule_event($time, 'hourly', 'dd_cron_rebill_expiry');   
#Rebill the user if their expiry date has been reached
function dd_rebill_expiry() {
  set_time_limit(0);  //will this work???

  //WP_User_Query goes here with 100 user maximum
  //Loop through all valid users & perform payment processing here

1 Answer 1


Further research has resulted in mixed information and no clear solution.

Our solution is to use a separate file and execute the script using CRON via the command-line, rather than relying on the Wordpress cron system. This has the added bonus of max_execution_time=0 as well. PHP Max execution time

Stripe's API seems to take about 2-3 seconds to process a transaction. If we limit our WP_User_Query to 100 users, that should take roughly 300-500 seconds to process an entire batch.

Since we are planning to execute our script hourly, I used set_time_limit=3500 (slightly under an hour), that way if something goes wrong it will be terminated before CRON executes the script again.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.