我试着定制wordpress来满足我的需求,我忙着做很多改变,但是我自己搞不清楚这一个。
我不想让作者为过去设置时间戳,我确实希望启用这个选项,但只允许在特性中发布新的帖子。所以最低要求的日期是今天,所以如果他们在今天之前选择一个日期,他们会收到一条消息或什么的,而帖子将不会进展。
有没有人知道我如何用插件或者过滤器来完成这个任务?
感谢每一个帮忙的人:)
发布于 2014-11-26 05:42:01
post是你所需要的。
add_action('save_post', 'stop_publishing', 20);
function stop_publishing($post_id)
{
$post = get_post($post_id);
$post_date = $post->post_date;
$current_date = date("Y-m-d");
//do your math of date calculation
//user has set a date in the past, I am using an imaginary variable date_is_not_valid
if ( $date_is_not_valid ) {
$message = '<p>Please enter current or future date.</p>'
. '<p><a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">Edit post</a></p>';
wp_die($message, 'Error - Incorrect Date!');
}
}
https://stackoverflow.com/questions/27141700
复制相似问题