diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php
index 468d6d6ea9..4d1d0db276 100644
--- a/wp-admin/includes/meta-boxes.php
+++ b/wp-admin/includes/meta-boxes.php
@@ -530,7 +530,8 @@ function post_author_meta_box($post) {
wp_dropdown_users( array(
'who' => 'authors',
'name' => 'post_author_override',
- 'selected' => empty($post->ID) ? $user_ID : $post->post_author
+ 'selected' => empty($post->ID) ? $user_ID : $post->post_author,
+ 'include_selected' => true
) );
}
diff --git a/wp-includes/user.php b/wp-includes/user.php
index b5677d0eb5..c30f7be830 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -957,6 +957,7 @@ function setup_userdata($for_user_id = '') {
*
show - Default is 'display_name'. User table column to display. If the selected item is empty then the user_login will be displayed in parentheses
* echo - Default is '1'. Whether to display or retrieve content.
* selected - Which User ID is selected.
+ * include_selected - Always include the selected user ID in the dropdown. Default is false.
* name - Default is 'user'. Name attribute of select element.
* id - Default is the value of the 'name' parameter. ID attribute of select element.
* class - Class attribute of select element.
@@ -977,7 +978,7 @@ function wp_dropdown_users( $args = '' ) {
'include' => '', 'exclude' => '', 'multi' => 0,
'show' => 'display_name', 'echo' => 1,
'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '',
- 'blog_id' => $GLOBALS['blog_id'], 'who' => ''
+ 'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false
);
$defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
@@ -1007,9 +1008,19 @@ function wp_dropdown_users( $args = '' ) {
$output .= "\t\n";
}
+ $found_selected = false;
foreach ( (array) $users as $user ) {
$user->ID = (int) $user->ID;
$_selected = selected( $user->ID, $selected, false );
+ if ( $_selected )
+ $found_selected = true;
+ $display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
+ $output .= "\t\n";
+ }
+
+ if ( $include_selected && ! $found_selected && ( $selected > 0 ) ) {
+ $user = get_userdata( $selected );
+ $_selected = selected( $user->ID, $selected, false );
$display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
$output .= "\t\n";
}