admin管理员组文章数量:1323715
I want to pass the $job_id variable to the expire_job_featured function (for wp single cron event) but I don't know how can I do that.
This is the full code of setting job's post meta value "featured" to 1 and then I want to schedule a single cron event to make the "featured" meta value to 0 after an hour. But I can't pass the $job_id variable to the expire_job_feature function.
add_action( 'init', function() {
$job_id = filter_input( INPUT_GET, 'feature_job', FILTER_VALIDATE_INT );
if ( null === $job_id ) {
return;
}
update_post_meta( $job_id, 'featured', 1 );
wp_schedule_single_event( time() + 3600, 'job_featured_expire' );
});
function expire_job_featured($job_id) {
update_post_meta( $job_id, 'featured', 0 );
}
add_action( 'job_featured_expire','expire_job_featured' );
本文标签: cronHow to pass variable from other function
版权声明:本文标题:cron - How to pass variable from other function? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742125613a2421925.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论