-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add: Get user ability. #10775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Add: Get user ability. #10775
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
|
(Sorry I missed this one. Wish there was a way we could actually tag other #core-ai folks for review. Will take it for a spin hopefully tomorrow or wednesday) |
Part of: WordPress/ai#40
Inspired by the work on https://github.com/galatanovidiu/mcp-adapter-implementation-example/tree/experiment/layerd-mcp-tools/includes/Abilities by @galatanovidiu.
cc: @JasonTheAdams, @justlevine
Summary
This PR adds a
core/get-userability to the WordPress Abilities API. This ability returns comprehensive profile details for a user by ID, login, or email.Organization
Following the pattern established in #10665 and #10747, this PR adds a new class
WP_Users_Abilitiesinsrc/wp-includes/abilities/class-wp-users-abilities.php. The class is organized into:register()method that registers all user-related abilitiesget_user_input_schema()andget_user_output_schema()define the ability's interfaceregister_get_user()registers the ability with schemas and callbackscheck_get_user_permission()validates access (logged in required, can view own profile, needslist_usersto view others)execute_get_user()retrieves and returns user dataKey Features
id,login, oremailto identify the userinclude_capabilitiesparameter to include all user capabilitieslist_userscapability to view other usersshow_in_rest: true)Test plan
http://localhost:6888/site-wp-dev-1/wp-admin/post-new.phpVerify error is returned when no identifier (id, login, or email) is provided
Test permission check: Verify non-logged-in users cannot access the ability
Test permission check: Verify non-admin users can only view their own user info
Test permission check: Verify users with
list_userscapability can view any user