How to not allow custom roles to edit published custom post types?

I have a WP site with a custom role (revisor) and a custom post type (events).

What I would like to do is allow my revisors to add new events, but not edit existing.

I’m already using the Members plugin, and i have ‘edit_published_events’ unchecked in it, but the users can still edit the events.

I think the problem is that I have another CPT that I want to let them edit (called listings), so I can’t fully restrict ‘edit_posts’ in the capabilities.

Any ideas on how I can just remove the option for editing a published CPT?
I did see a post about removing the ‘edit’ option that appears when you hover over the post’s name in the list, but clicking on the post still lets you edit…

Thanks!!!

1 Answer
1

Something like this (untested)

add_action( 'init', 'remove_revisor_cap_edit_posts' ); 

function remove_revisor_cap_edit_posts() {

if ( 'events' == get_post_type() ) {

$role = get_role( 'revisor' );
$role->remove_cap( 'edit_posts' );
    }
}

Leave a Comment