Skip to content

Allow pending posts to be previewed like drafts#115

Open
dChiamp wants to merge 2 commits into
mainfrom
fix-pending-preview
Open

Allow pending posts to be previewed like drafts#115
dChiamp wants to merge 2 commits into
mainfrom
fix-pending-preview

Conversation

@dChiamp

@dChiamp dChiamp commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Preview of pending posts was denied on the headless frontend, while drafts worked. Three places special-cased draft but never pending:

  • Utils\Post::url_to_postid() — the URI-to-post resolver limited its WP_Query to publish + draft, so a pending post was never found by URI (the /post endpoint 404'd before any read check). Same draft-only assumption in the verbose-page-rule branch.
  • REST_Post_Controller::check_read_permission() — the draft-only branch that re-derives the user (enabling cookie-based preview without a REST nonce) never ran for pending.
  • Utils\Post::can_user_read_post() — only handled draft and publish.

Fix

Treat pending the same as draft in all three. Authors can preview their own pending posts; editors/admins via read_private_posts.

Base bug — affects any fuxt site using a submit-for-review flow. Verified on staging: resolution and both read checks pass for a pending CPT post.

dChiamp added 2 commits July 1, 2026 11:03
check_read_permission() and can_user_read_post() special-cased 'draft' but not
'pending', so authenticated preview of pending posts fell through to a
publish-only check and was denied. Treat pending the same as draft in both
places.
url_to_postid() limited the resolving WP_Query to publish+draft, so pending
posts were never found by URI and /post 404'd before the read check ran. Add
'pending' to the status list and to the verbose-page-rule exemption.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant