1
我正在开发一个带有Edit Flow插件的Wordpress网站,因此我可以创建自定义发布状态以更轻松地管理作者和撰稿人帖子。Wordpress限制编辑,但允许预览自定义发布状态
所以我已经创建了自定义发布状态,并且我有以下过滤器来限制该帖子的编辑功能。它工作正常,但问题是用户(除管理员)无法预览帖子。其他用户仍然可以看到仪表板后列表中的“预览”链接,但如果他们点击它,并转到发布预览页面(../post-with-custom-status/?preview=true)它说,后可以”不被发现。
function restrict_edit_custom_status_posts($allcaps, $cap, $args) {
// Bail out if we're not asking to edit a post ...
if('edit_post' != $args[0]
// ... or user is admin
|| !empty($allcaps['manage_options'])
// ... or user already cannot edit the post
|| empty($allcaps['edit_posts']))
return $allcaps;
// Load the post data:
$post = get_post($args[2]);
// If post have custom status
if('my_custom_status' == $post->post_status) {
// Then disallow editing
$allcaps["edit_posts"] = FALSE;
return $allcaps;
}
return $allcaps;
}
add_filter('user_has_cap', restrict_edit_custom_status_posts10, 3);
那么有什么办法可以限制编辑功能,但允许预览?
[重复的问题在WPSE上](http://wordpress.stackexchange.com/questions/98505/restrict-edit-but-allow-preview-for-custom-post-status)。 – montrealist 2013-05-06 14:55:28
无限循环评论。 – Magicode 2013-08-19 14:01:16