Skip to content

Commit bfe6168

Browse files
committed
Make sure we always display something in the dropdown. See WordPress#7027.
git-svn-id: https://develop.svn.wordpress.org/trunk@9344 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d4f6abc commit bfe6168

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

wp-includes/user.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ function setup_userdata($user_id = '') {
427427
* <li>include - User IDs to include.</li>
428428
* <li>exclude - User IDs to exclude.</li>
429429
* <li>multi - Default is 'false'. Whether to skip the ID attribute on the 'select' element.</li>
430-
* <li>show - Default is 'display_name'. User table column to display.</li>
430+
* <li>show - Default is 'display_name'. User table column to display. If the selected item is empty then the user_login will be displayed in parentesis</li>
431431
* <li>echo - Default is '1'. Whether to display or retrieve content.</li>
432432
* <li>selected - Which User ID is selected.</li>
433433
* <li>name - Default is 'user'. Name attribute of select element.</li>
@@ -493,7 +493,8 @@ function wp_dropdown_users( $args = '' ) {
493493
foreach ( (array) $users as $user ) {
494494
$user->ID = (int) $user->ID;
495495
$_selected = $user->ID == $selected ? " selected='selected'" : '';
496-
$output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($user->$show) . "</option>\n";
496+
$display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
497+
$output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($display) . "</option>\n";
497498
}
498499

499500
$output .= "</select>";

0 commit comments

Comments
 (0)