I could be wrong as I don’t know how WordPress controls the dropdown menu but looks like it could be only returning a name of the author and not a link to their page.
I have tested the below code in a WordPress site environment and works including linking to the authors page.
<select name="author-dropdown" id="author-dropdown--1" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php echo esc_attr( __( 'Select Author' ) ); ?></option>
<?php
// loop through the users
$users = get_users('role=author');
foreach ($users as $user)
{
if(count_user_posts( $user->id ) >0)
{
// We need to add our url to the authors page
echo '<option value="'.get_author_posts_url( $user->id ).'">';
// Display name of the auther you could use another like nice_name
echo $user->display_name;
echo '</option>';
}
}
?>
</select>
Added update for making sure the authors have post and then added on administrator not sure how to combine the two roles without doing a duel foreach
<select name="author-dropdown" id="author-dropdown--1" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php echo esc_attr( __( 'Select Author' ) ); ?></option>
<?php
// loop through the users
$users = get_users('role=author');
foreach ($users as $user)
{
// get user who have posts only
if(count_user_posts( $user->id ) >0)
{
// We need to add our url to the authors page
echo '<option value="'.get_author_posts_url( $user->id ).'">';
// Display name of the auther you could use another like nice_name
echo $user->display_name;
echo '</option>';
}
}
$users = get_users('role=administrator');
foreach ($users as $user)
{
// get user who have posts only
if(count_user_posts( $user->id ) >0)
{
// We need to add our url to the authors page
echo '<option value="'.get_author_posts_url( $user->id ).'">';
// Display name of the auther you could use another like nice_name
echo $user->display_name;
echo '</option>';
}
}
?>
</select>