Skip to content

Let roles ticked in "Who can reorder" reorder posts they cannot edit - #161

Merged
puikinsh merged 1 commit into
masterfrom
fix/who-can-reorder-grant
Dec 1, 2026
Merged

puikinsh merged 1 commit into
masterfrom
fix/who-can-reorder-grant

Conversation

@puikinsh

@puikinsh puikinsh commented Dec 1, 2026

Copy link
Copy Markdown
Member

Fixes the forum report Permission Denied, not honouring the "Who can reorder" selection.

Problem

Ticking Contributor or Author under Who can reorder let those users past the access check, but every drag on the All view still failed with "Permission denied." A drag sends every row on the page, and since 2.8.3 each row must pass edit_post. Contributors can't edit published posts or other people's posts, and Authors can't edit other people's posts, so the page always contains a row that fails.

Change

  • A ticked role is permission to reorder. For a user holding a role ticked in allowed_roles, a post passes scporder_user_can_edit_post() when the user has the type's cap->edit_posts, the post's status is in order_post_statuses(), and, for a private status, the user passes read_post. That is the set of rows the type's All list shows them. The new check is user_may_reorder_listed_post().
  • No role ticked: unchanged. The strict per-row edit_post rule still applies.
  • Changing a parent still needs edit_post, because it changes the URL. The caller no longer guarantees this, so apply_post_parent_moves() now checks it itself.
  • The Order column's input and scpo_set_position use the same scporder_user_can_edit_post(). Ticked roles get a working input instead of a read-only number.
  • The setting's description now says that ticked roles can reorder items they can't edit.

Still refused for ticked roles: other users' private posts, trashed posts, and post types whose list the role can't open (for example Pages for Contributors).

Testing

  • tests/regression.php has a new section of 13 checks. The full suite passed 115/115 on a fresh WordPress 7.1.5 site (PHP 8.5, MariaDB). Against master's plugin code the new checks fail in the 5 expected places.
  • npm test: 133/133.
  • Over real HTTP as a Contributor on edit.php?all_posts=1 (20 rows, including published posts and other users' drafts), master returns Permission denied., while this branch saves and the reloaded list shows the new order.
  • Not run: http.sh and the Chrome e2e suite. No JS or CSS changed.

The changelog and version bump are left for the release commit.

🤖 Generated with Claude Code

A drag sends every row on the page, and each row had to pass edit_post, so
a Contributor or Author ticked in "Who can reorder" was refused every drag
on the All view (published and other people's posts are always there).
A ticked role now counts as permission to reorder rows of its own list:
the type's edit_posts cap, an orderable status, and read_post for private
statuses. With no role ticked the strict edit_post rule is unchanged.
Changing a parent still needs edit_post, now checked in
apply_post_parent_moves() itself. The Order column and scpo_set_position
use the same check.

Reported on the forum by northernbear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@puikinsh
puikinsh merged commit c8bf1b6 into master Dec 1, 2026
8 checks passed
@puikinsh puikinsh mentioned this pull request Dec 1, 2026
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