[wp-trac] [WordPress Trac] #51334: Implement enhanced post_status transition capabilities

WordPress Trac noreply at wordpress.org
Thu Sep 17 22:32:34 UTC 2020


#51334: Implement enhanced post_status transition capabilities
-----------------------------+-----------------------------
 Reporter:  derweili         |      Owner:  (none)
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Role/Capability  |    Version:
 Severity:  normal           |   Keywords:  2nd-opinion
  Focuses:                   |
-----------------------------+-----------------------------
 WordPress has some publishing related capabilities for post types
 including:

 `publish_posts`, `edit_published_posts`


 While working on multiple project with some custom user roles and while
 working on #47443 I noticed there could be some use cases that require
 more capabilities based on posts-status-changes.

 == Example use case

 When a user has the `edit_published_posts` but not `publish_posts`
 capability they can edit an already published posts but not publish a new
 posts/draft post.

 By editing a published post they can (accidentally) unpublish a post. If
 they did this by mistake, they don't have the possibility to revert this
 change.

 In most scenarios this is not intended.

 I can think about two ways how to solve this problem.

 == Solving this problem with an additional post type capability

 So I think an additional capability could be added which is responsible
 from switching from a published post_status to an unpublished status.

 == Solving this problem using filter hooks

 Because the solution is a bit unflexible I could also think about
 implementing a similar functionality by introducing one or more filter
 hooks like:

 - `can_transition_post_status` with a boolean value and the current and
 new status as additional arguments
 - `can_transition_{old_status}_to_{new_status}` with a boolean value and
 the post id as an additional argument

 Those filter hooks could be similar to the post transition action hook
 https://codex.wordpress.org/Post_Status_Transitions
 But those filters would run before updating the post.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51334>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list