Make WordPress Core

Opened 9 years ago

Last modified 4 months ago

#39939 new defect (bug)

A Contributor cannot preview their own post if it's scheduled

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: Role/Capability Keywords: needs-unit-tests close has-test-info has-screenshots has-patch
Focuses: administration Cc:

Description

Steps to reproduce:

  1. A Contributor writes a post and submits it for review. At this point they can preview their post.
  2. An Editor or Administrator approves the post and schedules it for publication at a later date.
  3. The contributor viewing the Posts listing table can no longer preview their post.

Previously: #33694

Change History (8)

#1 follow-up: @dhanendran
9 years ago

We don't have any specific cap for previewing a post. If we enable edit_post then contributor may edit the approved post and it may published on scheduled time before reviewed it again.

So the possible solution would be, we can add additional condition while showing the preview link and post preview cap change.

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

Replying to dhanendran:

We don't have any specific cap for previewing a post.

Good point. This reminds me that I started work on this a while ago but ended up down a rabbit hole: #33240

#3 @dhanendran
9 years ago

Instead of creating a new cap and patching it in several places, can we create a common hook which can alter the cap permissions. In this case, we can use a filter to remove Edit and Quick Edit from edit_post capability. So user use only preview option.

Just a thought...

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


4 months ago

#5 @SirLouen
4 months ago

  • Keywords close has-test-info has-screenshots added

Reproduction Report

Description

✅ This report still validates that the issue can be reproduced.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 139.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Testing Instructions

  • The ones provided by OP

Actual Results

  1. ✅ Error condition occurs (reproduced).

Additional Notes

  • The hook solution is adequate, but it feels like bread for today, hunger for tomorrow. Personally I also find that looking for the definitive solution provided in #33240 is the best option to go here. I'm adding close this in benefit to #33240, in case anyone wants to add anything else.

Supplemental Artifacts

Repro screenshot
https://i.imgur.com/7TQVyrb.png

#6 @SirLouen
4 months ago

  • Component changed from Posts, Post Types to Role/Capability

#7 @levinbaria
4 months ago

The future post status is marked as protected, which means contributors lose their normal edit capabilities once a post is scheduled. As a result, original authors currently cannot preview their own scheduled content.

I’ve implemented an approach that modifies the WP Query used for post controls so that the original post author can always preview their own content, regardless of post status. This is accomplished via a new filter,

author_can_preview_protected_post

, which provides a clean way for developers to customize or extend this behavior.

This ticket was mentioned in PR #9969 on WordPress/wordpress-develop by @levinbaria.


4 months ago
#8

  • Keywords has-patch added; needs-patch removed

This PR fixes the following things:

  • Now the Contributor can preview their own post, even when the post is scheduled.
  • Added on filter author_can_preview_protected_post which provides developer to customize this behaviour.

Trac ticket: https://core.trac.wordpress.org/ticket/39939

Note: See TracTickets for help on using tickets.