admin管理员组文章数量:1425918
So I have this block of code and it is driving me crazy:
if ( ! wp_next_scheduled( 'change_quote_hook_short' ) ) {
wp_schedule_event( time(), 'one_minute', 'change_quote_hook_short' );
}
add_action( 'change_quote_hook_short', 'get_next' );
function get_next() {
$new_ar = array ('Ad1', 'Ad2', 'Ad3', 'Ad4', 'Ad5');
$id = ++$_SESSION['ad_id'] % count($new_ar);
$_SESSION['ad_id'] = $id;
$rsmid_single = $new_ar[$id];
update_option('rsmid_single', $rsmid_single);
}
On each run of the function get_next, when I check $rsmid_single variable it changes value correctly. Still, the option in the table is always set at Ad2. I have also checked, cron is working (when I switch value for $rsmid_single, it shows in the table after one minute). Like update_option is executed before increment finished. If you can please tell me if this is possible or should I search for some alternative approach?
本文标签: sessionTrying to configure cron to get next value from array on each run
版权声明:本文标题:session - Trying to configure cron to get next value from array on each run 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745445515a2658644.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论