Wordpress的默认行为意味着贡献者无法发布新帖子。它们被保存为草稿并等待批准。但是,当贡献者编辑现有帖子时,他们可以在不需要批准的情况下发布他们的更改。
我想停止发布所有撰稿人的帖子编辑,而是将其设置为“待定”。
我尝试了以下但没有成功(functions.php)
$role = get_role('contributor');
if ( ! empty($role))
{
$role->remove_cap('publish_post');
}
答案 0 :(得分:0)
根据http://codex.wordpress.org/Roles_and_Capabilities,贡献者不应该具有编辑已发布帖子的能力。
可能你需要删除这样的功能:
$role = get_role( 'contributor' );
$role->remove_cap( 'edit_published_posts' );
答案 1 :(得分:0)
我不确定这是否是实现此目的的最佳方式,但是通过使用add_filter我可以在提交帖子后修改帖子状态。
在functions.php中
if (current_user_can('contributor'))
{
//function to set pending status
function dont_publish( $data , $postarr ) {
if ( in_category('mycategory') ) {
$data['post_status'] = 'pending';
}
return $data;
}
//apply the pending status
add_filter('wp_insert_post_data' , 'dont_publish' , '99', 2);
}
这也允许您仅对集合类别以及贡献者角色应用过滤器。