Skip to content

How should query abilities expose registered post, term, and user meta? #38

Backlog

Description

@euvoor

When a plugin registers a post, term, or user meta key with show_in_rest, should that also make the key eligible for reads through the corresponding query ability? Or should the plugin opt the key into abilities separately? I'd use the same rule for all three object types, as Grzegorz suggested in #17.

I tested this on single-site WordPress 7.1.5 and 7.2 RC2 with the abilities package at cfbdd91. For each object type, a REST request made as an administrator returned the registered test key and omitted a second key with show_in_rest disabled. With the same user and object, the query ability returned ability_invalid_input for both fields: ["meta"] and fields: ["meta.audit_visible"]. Original test results

The Elementor example on #22 gives this a practical use case. On a builder-managed page, the editable layout lives in post meta, and the builder regenerates post_content on save. A plugin may want to expose a field telling callers who manages that page.

Whichever opt-in we choose, I'd keep reads scoped to the key's registered object type and subtype, and to what the caller may see on that particular object. I'd decide writes separately.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions