Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
61a31d8
Add a core/user-create ability
jorgefilipecosta Oct 2, 2026
1bff26d
Add a core/user-update ability
jorgefilipecosta Oct 2, 2026
0c1c0d0
Add a core/user-delete ability
jorgefilipecosta Oct 2, 2026
3d52ef8
Say the users gate covers the user write abilities
jorgefilipecosta Oct 2, 2026
077d965
Add an e2e spec for the user write abilities
jorgefilipecosta Oct 2, 2026
aaf8e03
Check the parsed roles for a roles-only user update
jorgefilipecosta Oct 2, 2026
bb3fbf8
Read reassign strings as sent when input is coerced
jorgefilipecosta Oct 2, 2026
60feb27
Read the written user back without the site membership check
jorgefilipecosta Oct 2, 2026
796045b
Unregister the user write abilities after the users tests
jorgefilipecosta Oct 2, 2026
8c3cd20
Restore the super admins after the user write tests
jorgefilipecosta Oct 2, 2026
894948e
Drop the user category setup the test bootstrap already does
jorgefilipecosta Oct 2, 2026
b4e43b2
Drop the required-field tests the registration tests cover
jorgefilipecosta Oct 2, 2026
c637d51
Use core's missing user ID in the ported delete tests
jorgefilipecosta Oct 2, 2026
f5f5e90
Share the user management permission cases in the user tests
jorgefilipecosta Oct 2, 2026
2af99d9
Describe the write input sanitizing on its own terms
jorgefilipecosta Oct 2, 2026
65c16d0
Test that roles the user cannot give are refused
jorgefilipecosta Oct 2, 2026
54b12bd
Test that users who can list users get the created user's roles
jorgefilipecosta Oct 2, 2026
5b3ec13
Keep the default user order in the users query, matching core
jorgefilipecosta Oct 7, 2026
3e0fcd1
Declare the uri format for the user link and avatar URLs
jorgefilipecosta Oct 7, 2026
d12f439
Merge branch 'develop' into add/core-user-write-abilities
jorgefilipecosta Oct 7, 2026
a8b2a38
Note why the users query also sets show_in_rest
jorgefilipecosta Oct 7, 2026
f76b2d8
Expect the KSES script handling of the WordPress version under test
jorgefilipecosta Oct 7, 2026
6ea2f3d
Use block comments for multi-line comments in the users abilities
jorgefilipecosta Oct 7, 2026
2a64ae2
Explain why the users abilities live in a class
jorgefilipecosta Oct 7, 2026
0db00b9
Use block comments and distinct assertion messages in the users query…
jorgefilipecosta Oct 7, 2026
42f4d7f
Name the users query methods after the ability
jorgefilipecosta Oct 7, 2026
7b7dffe
Name the core class in the users abilities docblock
jorgefilipecosta Oct 7, 2026
ad417e4
Treat an empty roles list as a roles change in the user update
jorgefilipecosta Oct 7, 2026
deb0d0a
Return the deleted user from core/user-delete, without force
jorgefilipecosta Oct 7, 2026
4ecbee8
Rename the users gate class to Users
jorgefilipecosta Oct 7, 2026
a49f72b
Use verb-first labels for the user write abilities
jorgefilipecosta Oct 7, 2026
2ff4f2b
Set the public meta flag on the user write abilities
jorgefilipecosta Oct 7, 2026
0c20586
Report an unusable registered_date as null in the users query
jorgefilipecosta Oct 7, 2026
7ca8120
Let users read their own account on any site in the users query
jorgefilipecosta Oct 7, 2026
1d5f47e
Declare the object type at the root of the users query output schema
jorgefilipecosta Oct 7, 2026
5bb0920
Simplify the users abilities class
jorgefilipecosta Oct 7, 2026
1c19b20
Update the input coercion notes in the users query
jorgefilipecosta Oct 7, 2026
e63892f
Simplify the users query test fixtures
jorgefilipecosta Oct 7, 2026
b65d7d4
Cover more users query collection input
jorgefilipecosta Oct 7, 2026
4120928
Report a user the database refuses to create as an error
jorgefilipecosta Oct 7, 2026
48199eb
Count reordered roles as a roles change in the user update
jorgefilipecosta Oct 7, 2026
e0d2320
Require the promote capability to give a new user roles
jorgefilipecosta Oct 7, 2026
48f9195
Refuse deleting the current user's own account
jorgefilipecosta Oct 7, 2026
12e29d8
Make the password optional when creating a user
jorgefilipecosta Oct 7, 2026
70f653c
Say that deleting a user's content trashes posts and pages
jorgefilipecosta Oct 7, 2026
d7280fb
Label the users query ability Query Users
jorgefilipecosta Oct 7, 2026
6561555
Remove the label marker from the users query
jorgefilipecosta Oct 7, 2026
18a4876
Return every included user on one page in the users query
jorgefilipecosta Oct 7, 2026
7189ae9
Correct the include order note in the users query
jorgefilipecosta Oct 7, 2026
b005c58
Explain why the users query keeps its has_published_posts check
jorgefilipecosta Oct 7, 2026
b19154d
Simplify the string list normalizer in the users query
jorgefilipecosta Oct 7, 2026
2d28ae7
Accept an empty fields list in the users abilities
jorgefilipecosta Oct 8, 2026
4945532
Return not-found and page errors in the users query
jorgefilipecosta Oct 8, 2026
205485e
Find non-member public authors in the users query
jorgefilipecosta Oct 8, 2026
524d714
Return author fields to editors in the users query
jorgefilipecosta Oct 8, 2026
c7705e3
Align the users query with the content query
jorgefilipecosta Oct 8, 2026
44dfcfc
Say how the users query differs from `core/get-user-info`
jorgefilipecosta Oct 9, 2026
7b0d1f4
Keep the user ability callbacks private
jorgefilipecosta Oct 9, 2026
83c2cb8
Port core's error params and required ID to the users abilities
jorgefilipecosta Oct 9, 2026
254a11b
Type the users abilities' lists as list<>
jorgefilipecosta Oct 9, 2026
8fca7f8
Read the reassign and user IDs with parse_filter_int()
jorgefilipecosta Oct 9, 2026
5dca259
Remove the network user when a multisite create fails
jorgefilipecosta Oct 9, 2026
11cc67d
Cap the email address and display name at their column lengths
jorgefilipecosta Oct 9, 2026
ea81325
Ignore a slug that sanitizes to nothing
jorgefilipecosta Oct 9, 2026
29c7a68
List the role names in the write schema and reject duplicates
jorgefilipecosta Oct 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Read the written user back without the site membership check
  • Loading branch information
jorgefilipecosta committed Oct 2, 2026
commit 60feb27c940feb407eb3b95936767db0d7731bbd
10 changes: 2 additions & 8 deletions includes/Abilities/Users/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -1314,10 +1314,7 @@ public function execute_user_create( $input = array() ) {
}
}

$user = $this->get_user( $user_id );
if ( is_wp_error( $user ) ) {
return $user;
}
$user = new WP_User( $user_id );

if ( ! empty( $input['roles'] ) ) {
array_map( array( $user, 'add_role' ), $input['roles'] );
Expand Down Expand Up @@ -1395,10 +1392,7 @@ public function execute_user_update( $input = array() ) {
return $user_id;
}

$user = $this->get_user( $user_id );
if ( is_wp_error( $user ) ) {
return $user;
}
$user = new WP_User( $user_id );

if ( ! empty( $input['roles'] ) ) {
array_map( array( $user, 'add_role' ), $input['roles'] );
Expand Down
31 changes: 31 additions & 0 deletions tests/Integration/Includes/Abilities/Users/UserCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,37 @@ public function test_create_new_network_user_on_sub_site_adds_user_to_site(): vo
$this->assertTrue( $user_is_member );
}

/**
* On multisite, a user created on an archived site, which has no members, is returned with
* their roles.
*
* @group ms-required
*
* @since x.x.x
*/
public function test_create_on_an_archived_site_returns_the_user(): void {
if ( ! is_multisite() ) {
$this->markTestSkipped( 'This test requires a multisite installation.' );
}

$this->allow_user_to_manage_multisite();
$this->register_ability();

update_blog_status( get_current_blog_id(), 'archived', '1' );

$result = $this->create(
array(
'username' => 'archivedsiteuser',
'email' => 'archived-site-user@example.com',
'password' => 'password',
'roles' => array( 'editor' ),
)
);

$this->assertIsArray( $result, 'The user should be returned.' );
$this->assertSame( array( 'editor' ), array_values( get_userdata( $result['id'] )->roles ), 'The role should be added.' );
}

/**
* On multisite, creating a user whose username and email address are taken on the network
* returns both signup errors.
Expand Down