0

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!

  • For all users or for a specific user or role? – Brad Dalton Jan 3 '14 at 18:25
  • Hi Brad, for a role. – Trey Eckels Jan 3 '14 at 18:32
0

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.

| improve this answer | |
  • 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? – Trey Eckels Jan 3 '14 at 18:41
  • You can remove access to everything and only leave the CPT menu item wordpress.org/plugins/adminimize – Brad Dalton Jan 3 '14 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? – Trey Eckels Jan 3 '14 at 18:48
  • Plugin is the easiest otherwise here's the code wordpress.stackexchange.com/questions/9505/… – Brad Dalton Jan 3 '14 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? – Trey Eckels Jan 3 '14 at 18:55
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.