admin管理员组文章数量:1406943
Is it possible to set the capabilities of a role to allow editing of a custom content type but not editing of the regular post types? If so, how would I go about doing that? Thanks!
Is it possible to set the capabilities of a role to allow editing of a custom content type but not editing of the regular post types? If so, how would I go about doing that? Thanks!
Share Improve this question asked Jan 3, 2014 at 18:22 Trey EckelsTrey Eckels 1311 silver badge5 bronze badges 2- For all users or for a specific user or role? – Brad Dalton Commented Jan 3, 2014 at 18:25
- Hi Brad, for a role. – Trey Eckels Commented Jan 3, 2014 at 18:32
2 Answers
Reset to default 0You could install one of many plugins like this to restrict access for different user roles http://wordpress/plugins/advanced-access-manager/
Or you could remove the admin menu links to any items you want for a specific user using PHP code.
This worked for me - with no plugins. User that is allowed to edit/add only posts from custom type 'job':
add_action( 'current_screen', 'jobs_block_edit' );
function jobs_block_edit() {
global $current_screen;
$restricted = current_user_can('job_user') && (
($current_screen->base=='edit' && $current_screen->id!='edit-job') ||
($current_screen->base=='post' && $current_screen->id!='job')
);
if ($restricted) {
exit( wp_redirect( home_url( '/' ) ) );
}
}
本文标签: user rolesallow edit of custom post type but not regular posts
版权声明:本文标题:user roles - allow edit of custom post type but not regular posts? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744902261a2631413.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论