Display email address field next to author in wp_dropdown_users

the only filter hook called in wp_dropdown_users() function is wp_dropdown_users which pass a string of the dropdown in an html form so you can manipulate this dropdown at that hook with some major REGEX.

A better solution would be to use get_users() and create the dropdown your self, something like this:

$selected = 1; //just for example, you can get that by get_post_meta()
$siteusers = get_users(); // you can pass filters and option
$re="";
if (count($siteusers) > 0){
    $re="<select name="users_with_email">";
    foreach ($siteusers as $user) {
        $re .= '<option value="' . $user->ID . '">'.$user->user_nicename . ' ('.$user->user_email .')</option>';
    }
    $re .= '</select>';
    $re = str_replace('value="' . $selected . '"','value="' . $selected . '" selected="selected"', $re );
}
echo $re;

Leave a Comment