Skip to content

Instantly share code, notes, and snippets.

@marsch
Last active November 6, 2020 12:14
Show Gist options
  • Save marsch/35fe626859726498ee43c80965e881d2 to your computer and use it in GitHub Desktop.
Save marsch/35fe626859726498ee43c80965e881d2 to your computer and use it in GitHub Desktop.
<?php
/**
* Show WP author dropdown list
*
* @return array
*/
static function user_list() {
global $cv_admin_users_list;
if ( !empty( $cv_admin_users_list ) ) {
$result = $cv_admin_users_list;
} else {
$result = array();
$show = 'display_name';
$args = array(
'role__in' => [ 'author' ],
'fields' => array( 'ID', $show, 'user_login' ),
'orderby' => 'display_name',
'order' => 'ASC',
);
$users = get_users( apply_filters( PT_CV_PREFIX_ . 'user_list', $args ) );
foreach ( (array) $users as $user ) {
$user->ID = (int) $user->ID;
$display = !empty( $user->$show ) ? $user->$show : '(' . $user->user_login . ')';
$result[ $user->ID ] = esc_html( $display );
}
$cv_admin_users_list = $result;
}
return $result;
}
?>
@marsch
Copy link
Author

marsch commented Nov 6, 2020

key is line 17

just adding this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment