WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/23/2020 12:25:47 AM (15 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r49028 r49036  
    11921192            $found_selected          = false;
    11931193            $parsed_args['selected'] = (int) $parsed_args['selected'];
     1194
    11941195            foreach ( (array) $users as $user ) {
    11951196                $user->ID = (int) $user->ID;
     
    12001201
    12011202            if ( ! $found_selected ) {
    1202                 $users[] = get_userdata( $parsed_args['selected'] );
     1203                $selected_user = get_userdata( $parsed_args['selected'] );
     1204                if ( $selected_user ) {
     1205                    $users[] = $selected_user;
     1206                }
    12031207            }
    12041208        }
Note: See TracChangeset for help on using the changeset viewer.