Block Update Profile Errors


First, Jeff Farthing of theme-my-login pointed out that I was using add_filter instead of add_action, and helped to craft the first code below, however it still has the same problem, so this is a step in the right direction but is not my solution:

function tml_profile_errors( &$errors ) {
    if ( empty( $_POST['state'] ) )
        $errors->add( 'empty_missing_', '<strong>ERROR</strong>: Please enter your state.' );
add_action( 'user_profile_update_errors', 'tml_profile_errors' );

Second, I added the same validation step inside of my ‘personal_options_update’ and ‘edit_user_profile_update’ actions using the code below. Since this is run during the save step, it will prevent the user from saving and invalid value. There are a lot more fields than just ‘state’ for the form, which is why the example below uses a nested if rather than an && operator:

function tml_edit_user_profile_update( $user_id ) {
     if ( current_user_can('edit_user',$user_id) ) {
         if ( !empty( $_POST['state'] ) )
           update_user_meta( $user_id, 'state', $_POST['state'] );
add_action('personal_options_update', 'tml_edit_user_profile_update');
add_action('edit_user_profile_update', 'tml_edit_user_profile_update');