Change WordPress user roles and capabilities › Forums › How to or FAQ › Delete unpublished posts
- This topic has 3 replies, 2 voices, and was last updated 6 years, 2 months ago by Vladimir.
04/03/2017 at 13:10 #3409APSParticipant
I limit an editor’s role to the posts of certain contributors only using “Activate user access management to editing selected posts, pages, custom post types”.
I don’t allow either editors or contributors to delete published posts. But this means that they can’t delete “drafts” or “pending” posts either. Consequently, there is a multipication of unwanted unpublished posts in the “posts” section of both editors and contributors.
Is it possible to give editors permission to delete unpublished (pending and draft) posts of contributors they edit, and to give contributors the same permission to delete their own unpublished texts?
Thanks!05/03/2017 at 01:39 #3410VladimirKeymaster
Revoke from an editor’s role just a ‘delete_publish_posts’, but still grant to it the rest:
‘delete_posts’, ‘delete_others_posts’. This way editor role should be capable to delete draft and pending posts.
‘delete_posts’ granted to a ‘contributor’ role allows contributors to delete their own drafts.05/03/2017 at 06:40 #3411APSParticipant
Thanks for the reply! The solution for the contributor is perfect.
However, for the editor, it means that he can FIRST tansform a published post into a draft, and THEN delete it. But I don’t want to give editors the opportunity of deleting published articles.
Is there any way to avoid this two-step method of deleting published posts?
Thanks for your help!06/03/2017 at 03:11 #3412VladimirKeymaster
Editor is a power user. He can edit any attribute of a published post. It means that he can change its status (as you mentioned), he can change its permalink, he can just remove/replace full content of the post.
So 1st, I would think about stronger selecting of and more trust to so powerful users.
There is no built in functionality in WordPress to filter posts statuses list or prevent post status change at the post edit page. If user can publish post he can change its status to one of hard coded at wp-admin/includes/meta-boxes.php, function post_submit_meta_box().
It’s possible to write some code which will make any unpublished post back to the ‘published’ state. But I think that you will not wish to remove from editor this ability in case if he publish some post by mistake and wish return it back to a ‘draft’ or ‘pending’ status.
An example of changing post status after post saving is available here. You can use it as a starting point.
- You must be logged in to reply to this topic.