skip to Main Content

WordPress Code Snippets


How to Add ACF Fields to the My Account Page in WooCommerce

Want to customize the “My Account” page? This PHP code adds ACF fields, allowing users to input and save additional information. Enhance user experience effortlessly!

add_action('woocommerce_edit_account_form', 'codebykp_add_acf_fields_to_account');
function codebykp_add_acf_fields_to_account() {
    $field_value = get_field('custom_field_name', 'user_' . get_current_user_id());
    echo '<p class="form-row form-row-wide">
            <label for="custom_field_name">Custom Field</label>
            <input type="text" class="input-text" name="custom_field_name" id="custom_field_name" value="' . esc_attr($field_value) . '" />
          </p>';
}

add_action('woocommerce_save_account_details', 'codebykp_save_acf_fields_to_account');
function codebykp_save_acf_fields_to_account($user_id) {
    update_field('custom_field_name', $_POST['custom_field_name'], 'user_' . $user_id);
}


I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Best WordPress Hosting
Back To Top
Search