Repository navigation
Backport the core/users-query Ability - #3
Merged
Merged
Conversation
…ouldn't, matching some changes made in WP 7.2
…ut changes. Change load behavior a bit to be more efficient
nikmclaughlin
marked this pull request as ready for review
October 29, 2026 17:55
core/read-users Abilitycore/users-query Ability
Contributor
|
Merged — thanks @dkotter! Housekeeping note: after #2's squash merge, GitHub's "Update branch" reported conflicts (the stacked commits vs. the squashed #2 on |
This was referenced Oct 29, 2026
nikmclaughlin
added a commit
that referenced
this pull request
Oct 30, 2026
…lities from WordPress/ai PR #1105 (#9) ## What? Adds the three user write abilities to the package: a faithful port of WordPress/ai PR #1105 ("Add `core/user-create`, `core/user-update`, and `core/user-delete` abilities", author @jorgefilipecosta), incubating under the experimental tier's `wp/` prefix (D5). The upstream's `core/user-*` names are not adopted; no aliases exist (D7). Category `user` (tier experimental). ## Why? Agents can query users through abilities (PR #3's `core/users-query`) but not create, update, or delete them. This package ports the three writes so consumers get one canonical copy while the upstream proposal settles. ## How? - **The abilities:** `src/Users/Abstract_User_Write.php` (shared base) + `User_Create.php` / `User_Update.php` / `User_Delete.php` mirror the PR's logic — labels, descriptions, schemas (create requires `username` + `email`; update takes `id` and everything but `username`; delete requires `id` + `reassign`), annotations (create: `idempotent: false`; update: `destructive: true`/`idempotent: false` — DELETE would carry the password in the query string; delete: destructive idempotent, DELETE-served), error codes, the roles rules (empty list removes every role, self-role-removal and self-deletion prevented, users cannot be deleted on multisite, the delete answers with the user as it was — the password is never returned), and the set-password/email flow when a create omits the password. - **Shared state:** the field projection, normalization, and `format_user()`'s `$edit_context` write-side parameter live as self-contained verbatim copies of the package's `Users_Query` port — deliberately NOT a `Users_Query` extension or refactor, because the coreify round-trip gate diffs that class against the tracked core-trunk fixture (the B3 lesson). - **Companion (D2) verified, nothing ported:** the PR-side `core/users-query` changes (label "Query Users", username-ordered collections, the include-without-per_page max-page behavior, params-mapped filter errors, `id` required in the user output schema) are already present in the PR #3 core-7.2 backport; verification is pinned in the new suite. ## Use of AI tools Tool(s): goose (agent) Model(s): provided via the harness Used for: Implementation, tests, and docs. Reviewed and edited by the committer. ## Testing - New: `tests/Abilities/UserWritesTest.php` — the triad (success incl. the projected answers with the password never returned and the generated password; capability: create_users/promote_users/edit_user/delete_user gates, self-deletion and self-role-removal prevented, reassignment semantics with the posts moving; bad input: invalid username, empty password, unknown role, missing/repeat rows) + the companion users-query pin. - `composer run lint:phpcs`, `lint:phpstan`, `verify:manifest`, `verify:coreify` and the PHPUnit suite on BOTH wp-env environments (trunk then stable, one at a time, stopped between) pass. Co-authored-by: jorgefilipecosta <jorgefilipecosta@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
This branch is based off of #2, so leaving this in draft until that has been merged
What?
Adds
core/users-queryto the package as a backport of the ability that ships in WordPress 7.2.Depends on #2 (
core/settings-get), which this branch is built on. Until #2 merges, this PR also shows #2's commits.Why?
Brings the
core/users-queryAbility into this package, allowing consumers to get one canonical copy on WordPress 6.9–7.1. On 7.2+, core's copy is used and the package copy is skippedHow?
src/Users/Users_Query.phpwas generated from core's class withtools/coreify.php --reverseand matches it apart from the package wrapper.usercategory definition copied from core.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Implementation, tests, and an independent review pass. I reviewed and edited the result.
Testing Instructions
tools/wordpress-abilities-bridgeintowp-content/plugins/and activate WordPress Abilities Bridge. If you copy it rather than symlink it, adddefine( 'WP_ABILITIES_PACKAGE_PATH', '/path/to/wordpress-abilities' );towp-config.php.core/users-queryas registered.await wp.apiFetch( { path: '/wp-abilities/v1/abilities/core/users-query/run?input[fields][]=id&input[fields][]=username&input[fields][]=roles' } )It should return the site's users with their usernames and roles, plus pagination totals.
/wp-json/wp-abilities/v1/abilities/core/users-query/runin a private window (logged out). It should return a 401 "not allowed to execute this ability" error.usernameandrolesshould be left out, except on your own account if you're in the list.Changelog Entry