Skip to content

Commit

Permalink
Fix user fallback if user is not in initial batch for user_dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
robincornett committed Nov 27, 2020
1 parent 5978e87 commit 14372e8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions includes/class-edd-html-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,21 +339,21 @@ public function user_dropdown( $args = array() ) {
$options[0] = __( 'No users found', 'easy-digital-downloads' );
}

$selected = $args['selected'];
if ( ! is_array( $selected ) ) {
$selected = array( $selected );
}
// If a selected user has been specified, we need to ensure it's in the initial list of user displayed
if( ! empty( $args['selected'] ) ) {

if( ! array_key_exists( $args['selected'], $options ) ) {

$user = get_userdata( $args['selected'] );

if( $user ) {

$options[ absint( $args['selected'] ) ] = esc_html( $user->display_name );
if ( ! empty( $selected ) ) {
foreach ( $selected as $selected_user ) {
if ( ! array_key_exists( $selected_user, $options ) ) {
$user = get_userdata( $selected_user );

if ( $user ) {
$options[ absint( $args['selected'] ) ] = esc_html( $user->display_name );
}
}

}

}

$output = $this->select( array(
Expand Down

0 comments on commit 14372e8

Please sign in to comment.