admin管理员组文章数量:1122846
Im currently using User Role editor to modify permission for the user role. I'd like to be able to restrict the role from publishing a post. They can save the draft but they should not be able to publish. Is there a better way to do it?
Im currently using User Role editor to modify permission for the user role. I'd like to be able to restrict the role from publishing a post. They can save the draft but they should not be able to publish. Is there a better way to do it?
Share Improve this question asked Feb 21, 2020 at 18:34 Charles XavierCharles Xavier 1911 silver badge16 bronze badges 1- Not sure why you ask this, maybe I am wrong but that's just an option in User Role Editor. Select the role and add it to the role or just leave it inactive imho. – Charles Commented Feb 21, 2020 at 19:33
2 Answers
Reset to default 1Give the user the edit_posts
capability but not the publish_posts
capability.
Use wp_insert_post_data
filter. Then check the user role. If user have specific role set-up post status. ( I don't test below script)
add_filter( 'wp_insert_post_data', 'filter_handler', '99');
function filter_handler( $data ) {
$user = wp_get_current_user();
$userRole = $user->roles ? $user->roles[0] : false;
if ( $userRole === 'author') {
$data['post_status'] = 'pending';
}
return $data;
}
本文标签: allow user to create a draft post but not publish wordpress
版权声明:本文标题:allow user to create a draft post but not publish wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736282770a1926750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论