Repository navigation
Let roles ticked in "Who can reorder" reorder posts they cannot edit - #161
Merged
Merged
Conversation
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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
allowed_roles, a post passesscporder_user_can_edit_post()when the user has the type'scap->edit_posts, the post's status is inorder_post_statuses(), and, for a private status, the user passesread_post. That is the set of rows the type's All list shows them. The new check isuser_may_reorder_listed_post().edit_postrule still applies.edit_post, because it changes the URL. The caller no longer guarantees this, soapply_post_parent_moves()now checks it itself.scpo_set_positionuse the samescporder_user_can_edit_post(). Ticked roles get a working input instead of a read-only number.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.phphas 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.edit.php?all_posts=1(20 rows, including published posts and other users' drafts), master returnsPermission denied., while this branch saves and the reloaded list shows the new order.http.shand the Chrome e2e suite. No JS or CSS changed.The changelog and version bump are left for the release commit.
🤖 Generated with Claude Code