我正在开发一个会员系统,该系统将处理续期付款。
如果我使用set_time_limit(0)
内部wp_schedule_event
(cron)函数,这是否足以确保它有执行支付处理所需的时间?我们使用的是Stripe,我假设每个事务的API响应大约为1-2秒(希望更少),但如果我需要处理很多事务,我担心会遇到一般的30秒超时。
我更喜欢在运行时设置,而不是在php中全局设置。ini公司
代码示例:
//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
}