Opened 13 hours ago
Last modified 13 hours ago
#65234 assigned enhancement
Abilities API: Expand `core/get-user-info` with profile fields and filtering
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.1 | Priority: | normal |
| Severity: | normal | Version: | 6.9 |
| Component: | Abilities API | Keywords: | |
| Focuses: | Cc: |
Description
Two additive changes to core/get-user-info (shipped in 6.9):
- Expand the response with five standard profile fields:
first_name,last_name,nickname,description,user_url. - Add an optional
fieldsinput parameter that filters the response to a subset of properties, mirroring the pattern already used bycore/get-site-info.
Field naming follows WP-CLI conventions: wp_users columns keep their user_ prefix (user_url); user-meta fields are unprefixed (first_name, last_name, nickname, description).
Proposed shape
Default response (no fields parameter) after the change:
{ "id": 1, "display_name": "Jane Doe", "user_nicename": "jane-doe", "user_login": "jane", "roles": ["administrator"], "locale": "en_US", "first_name": "Jane", "last_name": "Doe", "nickname": "Jane", "description": "Site administrator and contributor.", "user_url": "https://example.com" }
Filtered response with fields: ["display_name", "first_name", "last_name"]:
{ "display_name": "Jane Doe", "first_name": "Jane", "last_name": "Doe" }
Behavioral rules
- Included by default, opt-out via
fields. Omittingfieldsreturns all properties, matchingcore/get-site-info. Passingfields: ["display_name"]filters down to just that property. - Schema-validated field names. Each entry in
fieldsmust be one of the declared output properties; invalid names are rejected by JSON Schemaenumvalidation. - Capability check unchanged:
is_user_logged_in(). - Annotations unchanged:
readonly: true,destructive: false,idempotent: true.
Acceptance criteria
core/get-user-inforeturns the five additional fields (first_name,last_name,nickname,description,user_url) alongside the existing 6.9 fields.core/get-user-infoaccepts an optionalfieldsinput parameter that filters the response to the requested subset.- When
fieldsis omitted, the response includes all properties. - Invalid field names in
fieldsare rejected via schema validation before execution. - JSON Schema documents each new field with
titleanddescriptionso adapters (MCP, WebMCP) can surface them. - Unit test coverage in
tests/phpunit/tests/abilities-api/for: expanded read output,fieldsfiltering with valid subset, schema rejection of invalid field names, and unauthenticated denial.
Note: See
TracTickets for help on using
tickets.