allow edit of custom post type but not regular posts?

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!

Related posts

2 comments

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

Comments are closed.