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
}