Is it possible to remove all references to ‘edit’ or ‘add’ from a particular post type on its post list display screen in admin?
So basically what I need is that for this post type, all roles defined, whatever they are, can only view a list of these posts, and not do anything with them except trash them. So that means removing the ‘Add New myposttype’ button, as well as the ‘Edit | Quick Edit’ links beneath each entry of the list posts screen.
In my custom post type these are my capability related settings:
'capability_type' => array('food_item','food_items'),
'map_meta_cap' => true,
'capabilities' => array(
'publish_posts' => 'publish_food_items',
'edit_posts' => 'edit_food_items',
'edit_others_posts' => 'edit_others_food_items',
'delete_posts' => 'delete_food_items',
'delete_others_posts' => 'delete_others_food_items',
'read_private_posts' => 'read_private_food_items',
'edit_post' => 'edit_food_item',
'delete_post' => 'delete_food_item',
'read_post' => 'read_food_item'
In my plugin init function, I’m adding the following:
global $wp_roles;
$wp_roles->add_cap( 'administrator', 'edit_food_item' );
$wp_roles->add_cap( 'administrator', 'edit_food_items' );
At this point the administrator just cannot see the food items entry in the menu at all.
For say the ‘moomin’ post type, when defining the custom post type specify its ‘capability_type’ as ‘moomin’.
This will give you the ‘capabilities’ edit_moomin’ etc which you can then remove from individual roles, e.g.:
@Simon Forster claims readonly posts IS possible, if so then this should do the job:
As requested…
I’ve added the read capability to the user roles. As I have not given anyone edit or delete.. they won’t have it. As I’ve given author and editor read access, they will have it.
In case you’re not sure what the capabilities will be, when you add the type as I have above you’ll generate the capabilities below
You could remove it by using some css in your plugin within the admin area
In your functions.php file link to some CSS (reference: http://codex.wordpress.org/Function_Reference/wp_enqueue_style)
The CSS:
In the CSS you’ll need to replace the references to ‘events’ with the name of your custom post type. This will work IE7+ I believe using those selectors.