Wordpress的默认行为意味着贡献者不能发布新帖子。它们被保存为草稿并等待批准。但是,当投稿人编辑现有帖子时,他们可以发布自己的更改,而无需批准。
我想停止发布所有投稿人帖子的编辑,而是将它们设置为"挂起"。
我尝试了以下操作,但没有成功(functions.php)
$role = get_role('contributor');
if ( ! empty($role))
{
$role->remove_cap('publish_post');
}
根据http://codex.wordpress.org/Roles_and_Capabilities投稿人不应具有编辑已发布帖子的能力。
可能你需要删除这样的功能:
$role = get_role( 'contributor' );
$role->remove_cap( 'edit_published_posts' );
我不确定这是否是实现这一目标的最佳方式,但通过使用add_filter,我可以在提交帖子后修改帖子状态。
在函数中.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);
}
这也允许您只对集合类别以及贡献者角色应用过滤器。