# Phone Number on the Account Details Form

> Adds the billing phone number to the My Account "Account details" form, so customers can update it in the same place as their name and email.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, my-account, phone, fields
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-account-phone-field/

## Code

```php
add_action( 'woocommerce_edit_account_form', function () {
    $phone = get_user_meta( get_current_user_id(), 'billing_phone', true );
    ?>
    <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
        <label for="account_phone"><?php echo esc_html( 'Phone number' ); ?></label>
        <input type="tel" class="woocommerce-Input input-text" name="account_phone" id="account_phone" autocomplete="tel" value="<?php echo esc_attr( $phone ); ?>">
    </p>
    <?php
} );

add_action( 'woocommerce_save_account_details_errors', function ( $errors ) {
    // phpcs:ignore WordPress.Security.NonceVerification -- WooCommerce verifies the account form nonce.
    $phone = isset( $_POST['account_phone'] ) ? wc_sanitize_phone_number( wp_unslash( $_POST['account_phone'] ) ) : '';

    if ( '' !== $phone && ! WC_Validation::is_phone( $phone ) ) {
        $errors->add( 'account_phone', 'Please enter a valid phone number.' );
    }
} );

add_action( 'woocommerce_save_account_details', function ( $user_id ) {
    // phpcs:ignore WordPress.Security.NonceVerification -- WooCommerce verifies the account form nonce.
    if ( isset( $_POST['account_phone'] ) ) {
        update_user_meta( $user_id, 'billing_phone', wc_sanitize_phone_number( wp_unslash( $_POST['account_phone'] ) ) );
    }
} );
```

## Notes

Saves to the same billing phone used at checkout, so both stay in sync.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Phone Number on the Account Details Form" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
