Skip to content

Instantly share code, notes, and snippets.

@alessandrotesoro
Created December 3, 2014 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessandrotesoro/5ed2dc1e4ec425c98c18 to your computer and use it in GitHub Desktop.
Save alessandrotesoro/5ed2dc1e4ec425c98c18 to your computer and use it in GitHub Desktop.
Display all users into the "Author" box
add_filter('wp_dropdown_users', 'tdp_custom_wp_dropdown_users');
function tdp_custom_wp_dropdown_users($output) {
global $post;
$users = get_users();
$output = "<select id=\"post_author_override\" name=\"post_author_override\" class=\"\">";
$output .= "<option value=\"1\">Admin</option>";
foreach($users as $user) {
$sel = ($post->post_author == $user->ID)?"selected='selected'":'';
$output .= '<option value="'.$user->ID.'"'.$sel.'>'.$user->user_login.'</option>';
}
$output .= "</select>";
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment