Tips / Recommendations

Add field to user profile wordpress and woocommerce

function my_user_contactmethods($user_contactmethods){
    $user_contactmethods['phone'] = 'Телефон';
    return $user_contactmethods;
}
add_filter('user_contactmethods', 'my_user_contactmethods');

<p class="form-row form-row-wide">
        <label for="phone">Phone</label>
        <input type="text" class="input-text" name="phone" id="phone" value="<?php echo esc_attr( $user->phone ); ?>" />
    </p>
    
    $phone  = ! empty( $_POST[ 'phone' ] ) ? $_POST[ 'phone' ] : '';
  $user->phone = $phone;