<?php
add_action( 'show_user_profile', 'profile_depart_field' );
add_action( 'edit_user_profile', 'profile_depart_field' );
function profile_depart_field( $user ) { ?>
<tr>
<th><label for="depart">Подразделение</label></th>
<td style="width: 200px" >
<input disabled="disabled" type="text" name="depart" value="<?php echo esc_attr( get_the_author_meta( 'depart', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
<td>
<select name="depart"> <!-- Тут -->
<?php
$depart = get_option('depart', array("Нет отделов"));
$curr = get_the_author_meta( 'depart', $user->ID );
foreach ($depart as $key => $value){
echo "<option id='depart' value='$value'>$value</option>";
}
?>
</select>
</td>
</tr>
<?php
add_action( 'personal_options_update', 'save_profile_depart_field' );
add_action( 'edit_user_profile_update', 'save_profile_depart_field' );
function save_profile_depart_field( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_usermeta( $user_id, 'depart', $_POST['depart'] );
}
?>