mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
Users: Check if the user ID passed as selected to wp_dropdown_users() corresponds to an existing user.
This avoids a few PHP notices if the `include_selected` parameter was specified and a non-existing user ID was passed. Props campusboy1987. Fixes #51370. git-svn-id: https://develop.svn.wordpress.org/trunk@49036 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1191,6 +1191,7 @@ function wp_dropdown_users( $args = '' ) {
|
||||
if ( $parsed_args['include_selected'] && ( $parsed_args['selected'] > 0 ) ) {
|
||||
$found_selected = false;
|
||||
$parsed_args['selected'] = (int) $parsed_args['selected'];
|
||||
|
||||
foreach ( (array) $users as $user ) {
|
||||
$user->ID = (int) $user->ID;
|
||||
if ( $user->ID === $parsed_args['selected'] ) {
|
||||
@@ -1199,7 +1200,10 @@ function wp_dropdown_users( $args = '' ) {
|
||||
}
|
||||
|
||||
if ( ! $found_selected ) {
|
||||
$users[] = get_userdata( $parsed_args['selected'] );
|
||||
$selected_user = get_userdata( $parsed_args['selected'] );
|
||||
if ( $selected_user ) {
|
||||
$users[] = $selected_user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user