Skip to content

fix(academy): let content staff edit media details - #1089

Merged
Genyus merged 1 commit into
developfrom
fix/content-staff-edit-media
Oct 30, 2026
Merged

Genyus merged 1 commit into
developfrom
fix/content-staff-edit-media

Conversation

@Genyus

@Genyus Genyus commented Oct 29, 2026

Copy link
Copy Markdown
Member

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_post on an attachment to edit_posts for the uploader and to edit_others_posts for everyone else. Content Editors and Reviewers have upload_files and edit_courses, but neither of those.

Fix

A new mu-plugin, cbf-staff-media-details.php, adds a map_meta_cap filter. For users who have edit_courses but not edit_posts, it maps edit_post on any attachment that isn't in the trash to edit_courses. This covers the media modal (save-attachment), the attachment edit screen and POST /wp/v2/media/<id>. Deleting still follows core's rules.

Testing

Tested locally through the REST API on an attachment another user uploaded:

Request Content Editor Subscriber
POST /wp/v2/media/<id> with description and alt text 200, both saved 403
DELETE /wp/v2/media/<id> 403 403

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=edit requests didn't actually send context, so they ran as view requests. I've now re-run them properly against develop. As a Content Editor, GET /wp/v2/blocks/5916?context=edit returns 200 with the raw content, and updating the pattern still returns 403. The fix works as described.

@Genyus
Genyus merged commit 5b76bde into develop Oct 30, 2026
4 checks passed
@Genyus
Genyus deleted the fix/content-staff-edit-media branch October 30, 2026 02:28
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