wp_usermeta – Read from database, but save function broken

You have not provided the whole code so don’t understand where you are wrong, this script is working fine for me.

add_action( 'personal_options_update', 'save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_profile_fields' );

function save_extra_profile_fields( $user_id )
{
    if ( current_user_can('edit_user',$user_id) )
        update_user_meta($user_id, 'uidnumber', sanitize_text_field($_POST['uidnumber']));
}

add_action('show_user_profile', 'show_extra_profile_fields');
add_action('edit_user_profile', 'show_extra_profile_fields');

function show_extra_profile_fields( $user )
{
    ?>
        <p class="form-row form-row-wide">
            <label for="uidnumber"><?php _e( 'UID-Nummer', 'woocommerce' ); ?></label>
            <input type="text" class="input-text" name="uidnumber" id="uidnumber" value="<?php echo get_user_meta( $user->ID, 'uidnumber', true ); ?>" />
        </p>
    <?php
}

EDIT : For frontend code

You have to save uidnumber through update_user_meta here is the code

global $user;

$user = wp_get_current_user();

if ( $_POST )   {

    update_user_meta( $user->ID, 'uidnumber', sanitize_text_field($_POST['uidnumber']) );
}

EDIT 2 : personal_options_update action only works in admin section, you have to put that code into front end check pastebin

enter image description here

  1. sanitize_text_field
  2. show_user_profile
  3. edit_user_profile
  4. personal_options_update
  5. edit_user_profile_update