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( '/' ) ) );
}
}