Make WordPress Core

Opened 9 years ago

Last modified 7 years ago

#33240 assigned enhancement

Introduce a capability for previewing posts

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Role/Capability Keywords: needs-patch, needs-unit-tests, granular-capabilities
Focuses: Cc:

Description

In order to preview an unpublished post (ie. draft or pending), a user needs the edit_posts capability for that post type (src).

There is a valid use case where a site requires a user role which has the capability to preview unpublished posts but not edit them, for example for editorial review/sign-off, layout review, early access, etc.

You can get around this by using a combination of the posts_results and the_posts filters, but this isn't very future-proof because the post results skip a bunch of logic that occurs between those two filters.

A preview_post meta capability and a preview_posts primitive capability could be introduced and implemented wherever the edit_posts capability is used in regard to previewing unpublished posts. By default, it will simply map to the edit_posts capability.

Thoughts?

Change History (8)

#1 follow-up: @morganestes
9 years ago

  • Focuses administration added

I think this could definitely be useful, especially with publishing shops that may not want to rely on a plugin for their editorial flow.

For implementation, would this be a checkbox on the user's profile page that is set by someone with a specific (filterable) capability (read-only for everyone else, maybe?) or would it be enabled through a hook, or some other way I haven't thought of?

#2 in reply to: ↑ 1 @DrewAPicture
9 years ago

Replying to morganestes:

I think this could definitely be useful, especially with publishing shops that may not want to rely on a plugin for their editorial flow.

For implementation, would this be a checkbox on the user's profile page that is set by someone with a specific (filterable) capability (read-only for everyone else, maybe?) or would it be enabled through a hook, or some other way I haven't thought of?

I think the most elegant way to do it would be to just give it to users who current have edit_posts by default, along the lines of the sub-cap concept (see the customize cap), thereby making it possible to programmatically remove the cap rather than add it.

#3 @johnbillion
8 years ago

  • Focuses administration removed
  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 4.7
  • Owner set to johnbillion
  • Status changed from new to assigned

#4 @johnbillion
8 years ago

  • Milestone changed from 4.7 to Future Release
  • Owner johnbillion deleted

This turns out to be more complicated that it first seems.

After patching several places in core with a preview_post capability check, I realised that previewing draft posts is a very different action to previewing changes to published posts, but they're both called previews.

We might need a collection of caps such as preview_published_posts, preview_others_posts, etc.

#5 @johnbillion
8 years ago

#22968 was marked as a duplicate.

#6 @archon810
8 years ago

@johnbillion Will you have time to tackle this again properly any time soon? It'd be a great feature for multi-user Wordpress installations everywhere.

#7 @johnbillion
8 years ago

I'd love to, but I won't have time to tackle it in the next few months due to other commitments.

#8 @flixos90
7 years ago

  • Keywords granular-capabilities added

All of these are part of a larger goal.

Note: See TracTickets for help on using tickets.