1
有没有办法限制WordPress可以编辑文章的次数?我不想限制存储在数据库中的修订版本。我希望用户只能在这里发帖3次。限制帖子编辑?
有没有办法限制WordPress可以编辑文章的次数?我不想限制存储在数据库中的修订版本。我希望用户只能在这里发帖3次。限制帖子编辑?
您可以在保存帖子上设置计数器并在更新帖子前进行检查。如果计数器crose限制,你可以不保存后返回..
这里的例子....
add_action('save_post', 'check_for_counter');
function check_for_count($ppost_id){
if(wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) {
return $post_id;
}
if(!current_user_can("edit_post", $post_id))
return $post_id;
$count = get_post_meta($post_id, 'revision_counter', true);
if(empty($count)){
update_post_meta($post_id, 'revision_counter', 1);
}else{
$count += 1;
update_post_meta($post_id, 'revision_counter', $count);
}
if($count == 3){
return $post_id;
}
}
请注意,我从来没有测试,但可以解决您的问题。
谢谢,但它不起作用。 –