Opened 6 months ago
Last modified 4 weeks ago
#64657 assigned enhancement
Add `core/read-users` ability
| Reported by: | jorgefilipecosta | Owned by: | jorgefilipecosta |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Abilities API | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description (last modified by )
Introduce a new Abilities API ability, core/read-users, to retrieve profile data for a specific user or a collection of users.
Core currently has core/get-user-info for the current authenticated user only. Agent/workflows use cases need to be able to look up any user when permissions allow it.
References
Change History (17)
This ticket was mentioned in PR #11434 on WordPress/wordpress-develop by @iamadisingh.
4 months ago
#2
- Keywords has-patch added
This ticket was mentioned in Slack in #core-ai by aditya_singh. View the logs.
4 months ago
This ticket was mentioned in PR #11525 on WordPress/wordpress-develop by @sangu3105.
4 months ago
#4
Ticket: 64657
Link: https://core.trac.wordpress.org/ticket/64657
Registered a new Ability of Get User info and Show_in_rest is true.
#5
@
4 months ago
- Component AI → Abilities API
Moving tickets related to the Abilities API to a new sub-component.
#7
@
3 months ago
Removing trunk version as this is not going to be shipped with WP 7.0 but in the next releases.
#8
@
3 months ago
- Keywords abilities removed
Removing abilities and abilities-api custom keywords. This is now indicated by the Abilities API component.
#9
@
3 months ago
- Keywords abilities added
- Version trunk
Since this is an enhancement, there's no first version of WordPress this can be reproduced in. Removing trunk version.
#10
@
3 months ago
- Milestone Future Release → 7.1
#65234 added several enhancements to core/get-user-info like more supported fields (most of these listed in the description of this ticket), a way to filter which fields get returned. For me, it looks like the best past forward is to extend the existing ability by allowing passing the user identifier as proposed here:
Require one of: id (integer), username (string), or email (string).
Following the user permission validation:
- User must be logged in.
- Users can view their own record.
- Viewing other users requires
list_users.
Two firsts conditions are implemented, so it all boils down to the third condition when viewing other user profiles.
@mukesh27 commented on PR #11434:
2 months ago
#12
Closing in favour on #11525
#13
@
6 weeks ago
- Description modified (diff)
- Summary Add `core/get-user` ability → Add `core/read-users` ability
This ticket was mentioned in PR #10775 on WordPress/wordpress-develop by @jorgefilipecosta.
6 weeks ago
#14
- Keywords has-unit-tests added
## What?
- Adds a read-only
core/usersability registered from Core ability registration. - Supports single-user lookup by
id,user_email,user_login, oruser_nicename. - Supports collection mode with optional
roles,has_published_posts,page,per_page, andfields; omitted REST input defaults to empty collection mode. - Uses WP_User-shaped field names, including
user_login,user_email,user_nicename,user_url, anduser_registered, to align with Core’s existingcore/get-user-infoability. - Aligns access checks with the REST users controller: non-list users only see public authors in collection mode, role filtering requires
list_users, user email/login lookup for another user requireslist_usersoredit_user, and inaccessible fields are omitted per user. - Excludes capabilities, extra capabilities, and meta;
avatar_urlsis available only whenget_option( 'show_avatars' )is enabled.
Ticket: https://core.trac.wordpress.org/ticket/64657
## Testing
php -l src/wp-includes/abilities/class-wp-users-abilities.phpphp -l src/wp-includes/abilities.phpphp -l tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.phpphp ./vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 src/wp-includes/abilities.php src/wp-includes/abilities/class-wp-users-abilities.php tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.phpphp ./vendor/bin/phpunit --filter Tests_Abilities_API_WpRegisterCoreUsersAbility --group abilities-apiphp ./vendor/bin/phpunit --group abilities-apigit diff --check
#15
@
6 weeks ago
- Description modified (diff)
- Keywords abilities removed
Core currently has core/get-user-info for the current authenticated user only (and not exposed in REST).
I updated that part, as all core abilities are now exposed through the REST API. I didn't find any evidence that an exception should be kept for core/get-user-info.
@gziolo commented on PR #10775:
4 weeks ago
#16
Thanks @jorgefilipecosta! I checked this port against the merged AI plugin version (WordPress/ai#774), and it reflects it faithfully. The class body, schemas, permission model, and normalizers are the same, with only the expected Core adaptations (no namespace, no ai text domain, docblocks, and dropping the plugin-only override/init() hook). Test coverage matches too, minus the one plugin-only override test that has no meaning in Core. Nice work keeping the two in sync.
Before this lands, I think we should settle the two points I raised in the comments: the class naming convention (the WP_Abilities_ prefix, shared with the settings PR) and how this ability sits next to the existing core/get-user-info. Since nothing has shipped yet, this is the moment to align the field names and reuse one shared definition source, so we do not freeze two vocabularies for the same user data. That is the last step for me before approval.
The CI failures look unrelated. The run has a single failing test, test_new_admin_email_subject_filter (an admin email subject assertion), while all the abilities tests pass. It looks like test-state pollution, so a rebase or re-run should clear it.
#17
@
4 weeks ago
- Description modified (diff)
- Milestone 7.1 → 7.2
Moved to WordPress 7.2 based on the decision made after evaluating feedback on the merge proposal.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Adds a new
core/get-userability to the Abilities API that retrieves profile data for a specific user byid,username, oremail. User must be logged in. Users can view their own record. Viewing other users requireslist_users.Trac ticket: https://core.trac.wordpress.org/ticket/64657
## Use of AI Tools