You are storing the data in the $selected
value, while using $topselected
in the conditionals to check which value is selected.
Either change your value like this:
$topselected= get_the_author_meta( 'user_top', $user->ID );
OR change your inline conditionals to this:
<option value="MPF Pune West:" <?php echo ($selected== "MPF Pune West:")? 'selected="selected"' : '' ?>>MPF Pune West:</option>
UPDATE
Based on @birgire’s comments, you can use the built in selected()
function:
<select name="user_top" id="user_top">
<option value="MPF Pune Central:" <?php selected( $selected , "MPF Pune Central:" ); ?>>MPF Pune Central:</option>
<option value="MPF Pune East:" <?php selected( $selected , "MPF Pune East:" ); ?>>MPF Pune East:</option>
<option value="MPF Pune West:" <?php selected( $selected , "MPF Pune West:" ); ?>>MPF Pune West:</option>
<option value="MPF Pune South:" <?php selected( $selected , "MPF Pune South:" ); ?>>MPF Pune South:</option>
<option value="MPF PCMC:" <?php selected( $selected , "MPF PCMC:" ); ?>>MPF PCMC:</option>
</select>