I’m actually building custom type to WP and need to be able to restrict post access to some user role, ie. in admin area, collaborators can see posts but can’t edit them, just only open them as read-only. I used some plugins (Adminimize and User Role Editor) but, as far as I know, they don’t apply to my needs.
Does any one give me directions in order to solve this?
brasolfilo’s suggestion that you remove the submit meta box is only part of what I’d consider a complete solution. I can hack a “submit” button into that page using FireBug or any of a few other tools, in a matter of minutes.
I would…
post-new.php
for that post type for users who should have only read-only access.The following code uses the ‘Book’ post type that can be found in the Codex. You can modify it to match your CPT.
Remove access to
post-new.php
Remove the “Add New” Menu
Alter the “Add New” link on the Edit page
Prevent sneaky submissions
I think has got it. It seems to work as I’ve been testing it, but I would not be surprised if there were bugs, especially in that last block of code, nor would I be surprised if there were more elegant ways of doing some of the same things. Caveat Emptor. No refunds.
If you simply remove the meta box, there’s no way of saving/updating the post. Tested here with the regular Post post type:
There could be issues with Autosave and Revisions.
Other solution would be making the fields read-only with jQuery, but maybe it’s not very solid.
Finally, another option would be removing the Title and Content fields and printing simple text in replacement.