Make WordPress Core

Changeset 63544


Ignore:
Timestamp:
09/08/2026 09:30:28 PM (6 weeks ago)
Author:
joedolson
Message:

Multisite: Restore missing user reassignment dropdown when deleting user.

Explicitly pass the blog_id attribute to wp_dropdown_users in confirm_delete_users() so that the dropdown renders the list of users appropriate to the current site, rather than attempting to fallback to the main site despite the limits set by the include parameter, which limited to members of the subsite. This resulted in an empty list in any case where there was no overlap between members of the current subset and members of the primary network site.

Props mgyura, johnbillion, adamsilverstein, joedolson.
Fixes #66012.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ms.php

    r63008 r63544  
    10041004                                                                                                'show'    => 'display_name_with_login',
    10051005                                                                                                'id'      => "reassign_user_{$details->userblog_id}_{$delete_user->ID}",
     1006                                                                                                'blog_id' => $details->userblog_id,
    10061007                                                                                        )
    10071008                                                                                );
  • trunk/tests/phpunit/tests/user/wpDropdownUsers.php

    r54090 r63544  
    202202                $this->assertStringContainsString( $u2->user_login, $found );
    203203        }
     204
     205        /**
     206         * @ticket 66012
     207         * @group ms-required
     208         */
     209        public function test_multisite_users_in_blog_id() {
     210                $blog_id = self::factory()->blog->create();
     211                $users   = self::factory()->user->create_many( 2 );
     212
     213                add_user_to_blog( $blog_id, $users[0], 'author' );
     214                add_user_to_blog( $blog_id, $users[1], 'author' );
     215
     216                // The main site has no authors, so the dropdown should be empty.
     217                $found_main_site = wp_dropdown_users(
     218                        array(
     219                                'echo'    => false,
     220                                'role'    => 'author',
     221                                'show'    => 'user_login',
     222                                'blog_id' => get_current_blog_id(),
     223                        )
     224                );
     225
     226                $this->assertSame( '', $found_main_site );
     227
     228                $found_sub_site = wp_dropdown_users(
     229                        array(
     230                                'echo'    => false,
     231                                'role'    => 'author',
     232                                'show'    => 'user_login',
     233                                'blog_id' => $blog_id,
     234                        )
     235                );
     236
     237                $user1 = get_userdata( $users[0] );
     238                $user2 = get_userdata( $users[1] );
     239
     240                $this->assertStringContainsString( $user1->user_login, $found_sub_site );
     241                $this->assertStringContainsString( $user2->user_login, $found_sub_site );
     242        }
    204243}
Note: See TracChangeset for help on using the changeset viewer.