试试这个
/* Save selected data */
add_action( \'personal_options_update\', \'save_user_fields\' );
add_action( \'edit_user_profile_update\', \'save_user_fields\' );
function save_user_fields( $user_id ) {
if ( !current_user_can( \'edit_user\', $user_id ) )
return false;
update_usermeta( $user_id, \'country\', $_POST[\'country\'] );
}
add_action( \'show_user_profile\', \'Add_user_fields\' );
add_action( \'edit_user_profile\', \'Add_user_fields\' );
function Add_user_fields( $user ) {
?>
<h3>Additional Field</h3>
<table class="form-table">
<tr>
<th><label for="dropdown">Select field</label></th>
<td>
<?php
//get dropdown saved value
$selected = get_the_author_meta( \'country\', $user->ID );
?>
<select name="country" id="country">
<option value="Argentina" <?php echo ($selected == "Argentina")? \'selected="selected"\' : \'\'; ?>>Argentina</option>
<option value="Belgium" <?php echo ($selected == "Belgium")? \'selected="selected"\' : \'\'; ?>>Belgium</option>
<option value="countryX" <?php echo ($selected == "countryX")? \'selected="selected"\' : \'\'; ?>>country X</option>
</select>
<span class="description">Select the above</span>
</td>
</tr>
</table>
<?php
}
?>
希望这能帮到你。