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.
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, providing more data than the existingcore/get-user-infoability.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