Skip to content

fix(academy): let content staff view synced patterns in the editor - #1086

Merged
Genyus merged 1 commit into
developfrom
fix/content-editor-synced-patterns
Oct 29, 2026
Merged

Genyus merged 1 commit into
developfrom
fix/content-editor-synced-patterns

Conversation

@Genyus

@Genyus Genyus commented Oct 29, 2026

Copy link
Copy Markdown
Member

Content Editors and Reviewers can't see synced patterns. In lessons, every Learning checkpoint, Q&A and Break block shows "Block has been deleted or is unavailable", and the inserter lists no synced patterns. The patterns exist and the lessons reference the right IDs (for example, 5916 in lesson 7241).

Cause

Core maps reading a synced pattern (wp_block) to edit_posts. The block editor loads each pattern with context=edit, which also needs edit_post on the pattern itself (WP_REST_Posts_Controller::get_item_permissions_check). Listing patterns in that context needs edit_posts. Content Editors and Reviewers have edit_courses but not edit_posts, so they get 403s on single patterns and an empty or forbidden list.

Fix

A new mu-plugin, cbf-staff-synced-patterns.php, applies only to users who have edit_courses but not edit_posts:

  • A map_meta_cap filter maps read_post on a published wp_block to edit_courses.
  • A rest_request_before_callbacks filter changes context=edit GET requests on /wp/v2/blocks and /wp/v2/blocks/<id> to view. For patterns, the view context still returns title.raw and content.raw, which is all the editor needs.

These users still can't edit patterns, so the editor doesn't offer "Edit original". Patterns keep changing in their source files and reach the site through wp cbf patterns sync.

Testing

Tested locally through the REST API:

Request Content Editor before Content Editor after Subscriber after
GET /wp/v2/blocks/5916 (view/edit) 403 200 with raw content 403 (unchanged)
GET /wp/v2/blocks (view/edit) 0 items / 403 Q&A, Break, Learning checkpoint 0 items / 403 (unchanged)
PUT /wp/v2/blocks/5916 403 403 403

Not yet checked in the block editor in a browser. After deploy, open lesson 7241 as a Content Editor and confirm the three checkpoints render and the patterns appear in the inserter.

phpcs passes.

@Genyus
Genyus merged commit 95803f6 into develop Oct 29, 2026
4 checks passed
@Genyus
Genyus deleted the fix/content-editor-synced-patterns branch October 29, 2026 20:53
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