Repository navigation
fix(academy): let content staff edit media details - #1089
Merged
Merged
Conversation
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.
Content Editors and Reviewers can upload media but can't edit any attachment's title, alt text, caption or description, including files they uploaded themselves. One editor couldn't add source references to WebP images or correct the note on attachment 8325.
Cause
Core maps
edit_poston an attachment toedit_postsfor the uploader and toedit_others_postsfor everyone else. Content Editors and Reviewers haveupload_filesandedit_courses, but neither of those.Fix
A new mu-plugin,
cbf-staff-media-details.php, adds amap_meta_capfilter. For users who haveedit_coursesbut notedit_posts, it mapsedit_poston any attachment that isn't in the trash toedit_courses. This covers the media modal (save-attachment), the attachment edit screen andPOST /wp/v2/media/<id>. Deleting still follows core's rules.Testing
Tested locally through the REST API on an attachment another user uploaded:
POST /wp/v2/media/<id>with description and alt textDELETE /wp/v2/media/<id>Not yet checked in the media modal in a browser.
phpcs passes.
Correction to #1086
The testing table in #1086 overstated what had been checked at the time. Its single-pattern
context=editrequests didn't actually sendcontext, so they ran asviewrequests. I've now re-run them properly againstdevelop. As a Content Editor,GET /wp/v2/blocks/5916?context=editreturns 200 with the raw content, and updating the pattern still returns 403. The fix works as described.