Skip to content

Post Editor: 403 on /wp/v2/settings at boot for users without manage_options cap #81812

Closed

Description

@hbhalodia

Description

While working on the PR feedback here, I re-verify the PR changes for low cap users and found the console error that was unrelated to the PR, but still was present. On further debug found the below cause,

Every time a user without manage_options opens the post editor, the console logs a failed request:

GET http://example.com/wp-json/wp/v2/settings?_locale=user 403 (Forbidden)
    at preloadResolutions (packages/edit-post/src/index.js:197)
    at initializeEditor (packages/edit-post/src/index.js:131)

Nothing visibly breaks - the rejection is swallowed by the catch {} at the end of preloadResolutions() - but every Editor, Author and Contributor sees this 403 console error.

Step-by-step reproduction instructions

  1. Add a user with the Author role (Editor or Contributor reproduce it equally).
  2. Log in as that user and open Posts → Add New.
  3. Open the browser console, or the Network tab filtered on settings.
  4. A GET /wp-json/wp/v2/settings returns 403.

Administrators never see it, which is why it went unnoticed.

Console Error Details: index.ts:86 GET http://localhost:8188/wp-json/wp/v2/settings?_locale=user 403 (Forbidden) (anonymous) @ index.ts:86 (anonymous) @ fetch-all-middleware.ts:77 (anonymous) @ index.ts:178 (anonymous) @ http-v1.ts:39 (anonymous) @ index.ts:178 (anonymous) @ namespace-endpoint.ts:26 (anonymous) @ index.ts:178 (anonymous) @ user-locale.ts:19 (anonymous) @ index.ts:178 (anonymous) @ root-url.ts:37 (anonymous) @ namespace-endpoint.ts:26 (anonymous) @ root-url.ts:11 (anonymous) @ index.ts:178 (anonymous) @ nonce.ts:28 (anonymous) @ index.ts:178 (anonymous) @ media-upload.ts:28 (anonymous) @ index.ts:178 (anonymous) @ preloading.ts:63 (anonymous) @ index.ts:178 (anonymous) @ index.ts:183 (anonymous) @ resolvers.js:127 await in (anonymous) (anonymous) @ thunk-middleware.ts:6 (anonymous) @ index.ts:27 (anonymous) @ promise-middleware.ts:17 (anonymous) @ resolvers-cache-middleware.ts:53 (anonymous) @ index.ts:806 setTimeout fulfillSelector @ index.ts:798 (anonymous) @ index.ts:821 (anonymous) @ index.ts:672 (anonymous) @ index.ts:675 (anonymous) @ index.ts:644 preloadResolutions @ index.js:197 initializeEditor @ index.js:131 (anonymous) @ wp-edit-post-js-after:5
Image

Why it happens

  1. wp-admin/edit-form-blocks.php server-preloads /wp/v2/settings for the post editor.
  2. rest_preload_api_request() caches only 200 responses (if ( 200 === $response->status )).
  3. WP_REST_Settings_Controller::get_item_permissions_check() returns current_user_can( 'manage_options' ), so for these roles the preload is a 403 and is therefore never cached.
  4. preloadResolutions() resolves root/site unconditionally, so with an empty preload cache the request escapes to the network.

For an administrator step 3 yields a 200, the preload cache is populated, and the resolution is served locally without any network request - hence the role-dependent behaviour.

The capability check is already right there, one line below the fetch it should be guarding:

// packages/edit-post/src/index.js
core.getEntityRecord( 'root', 'site' ),                    // line 197
core.canUser( 'read', { kind: 'root', name: 'site' } ),    // line 198

Both sit in the same Promise.all, so the gate cannot be applied where it stands.

Regressed in

#78508, which added preloadResolutions(). Before that commit packages/edit-post/src/index.js performed no resolutions at boot, so root/site was only ever fetched by callers that gate it - for example useBlockEditorSettings:

It was added in GB version 23.3.0 and it's present from that version.

const siteSettings = canUser( 'read', { kind: 'root', name: 'site' } )
    ? getEntityRecord( 'root', 'site' )
    : undefined;

Suggested fix

preloadResolutions() already has a second stage — "Phase 2: read derived data out of state" — that runs after the first Promise.all settles. Moving the root/site preload there, conditional on the resolved canUser( 'read', … ) value, fixes it in the shape the function already uses:

// Phase 1 keeps the capability check.
core.canUser( 'read', { kind: 'root', name: 'site' } ),

// Phase 2, once it has resolved.
if ( coreSelect.canUser( 'read', { kind: 'root', name: 'site' } ) ) {
    tasks.push( core.getEntityRecord( 'root', 'site' ) );
}

That costs low-capability users nothing and leaves administrators unaffected, since their settings response is already in the preload cache.

Environment info

  • WordPress latest.
  • Gutenberg trunk

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Cc: @ellatrix for review as original author of the PR which shows regression.

Note: I have used claude code to draft the issue description. Have reviewed it myself before posting.

Activity

  1. added
    [Type] Bug
    on Aug 19, 2026
  2. added theissue type on Aug 19, 2026
  3. added
    [Type] Regression
    [Package] Edit Post
    on Aug 19, 2026
  4. changed the title [-]Post Editor: 403 on /wp/v2/settings at boot for users without manage_options[/-] [+]Post Editor: 403 on /wp/v2/settings at boot for users without manage_options cap[/+] on Aug 19, 2026
  5. added
    [Status] In Progress
    on Aug 19, 2026
  6. removed
    [Type] Bug
    on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Package] Edit Post[Status] In Progress[Type] Regression

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions