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!
2 Answers
You could install one of many plugins like this to restrict access for different user roles http://wordpress.org/plugins/advanced-access-manager/
Or you could remove the admin menu links to any items you want for a specific user using PHP code.
-
Thanks brad! I thought about removing the links from the admin panel but I was concerned that a sneaky user could just go straight to the create new page by guessing the direct link. Or am I overthinking this? Commented Jan 3, 2014 at 18:41
-
You can remove access to everything and only leave the CPT menu item wordpress.org/plugins/adminimize Commented Jan 3, 2014 at 18:43
-
Basically I have a custom type organization and users will be associated with one org per user. An org can be associated to many users. Each user should be able to edit only the org post they are associated to and not be able to edit regular posts. What do you think is the best way to accomplish that? Commented Jan 3, 2014 at 18:48
-
Plugin is the easiest otherwise here's the code wordpress.stackexchange.com/questions/9505/… Commented Jan 3, 2014 at 18:49
-
One last question. If I remove the cap to edit posts, that will also remove cap to edit custom posts too right, even if I give a role to a user to edit the custom type? Do you have to have the ability to edit posts to edit custom type posts? Commented Jan 3, 2014 at 18:55
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( '/' ) ) );
}
}