---
title: "nxt/update_value — Change a Field Value Before It Is Saved"
url: https://nexterwp.com/docs/nxt-update-value-filter/
date: 2026-11-12
modified: 2026-11-12
lang: en
author: "Aditya Sharma"
description: "nxt/update_value runs just before a value is written. Use it to normalise, clean or derive what actually gets stored. What It Does The filter receives the value on its way..."
image: https://nexterwp.com/wp-content/uploads/2026/09/nxt-update-value-filter-1024x519.jpg
word_count: 296
---

# nxt/update_value — Change a Field Value Before It Is Saved

`nxt/update_value` runs just before a value is written. Use it to normalise, clean or derive what actually gets stored.

## What It Does

The filter receives the value on its way in, the field definition and the object ID. What you return is what lands in the database.

## Before You Start

- Nexter Extension 4.9.0 or later with Content Fields enabled.- Somewhere to add PHP — a child theme’s `functions.php`, a small plugin, or a Nexter code snippet.- You know the field or post type key you want to affect.

## Filter a Saved Value

- Add a filter on `nxt/update_value` with three arguments.

![A field group on the post editing screen, where values are entered](https://nexterwp.com/wp-content/uploads/2026/09/nxt-fields-s-metabox-drawer-open.webp)

- Test the field name so you only affect the field you mean.

- Return the value you want stored — or the original, untouched.

- Save a post and check the stored value, not just the screen.

## When to Use It

- Forcing a consistent case or format on a code.- Stripping characters an import brought in.- Deriving one value from another at save time.

## Display the Value

Normalising a reference code on save:

`<?php
add_filter( 'nxt/update_value', function ( $value, $field, $object_id ) {
if ( 'reference' !== $field['name'] ) {
return $value;
}
return strtoupper( trim( (string) $value ) );
}, 10, 3 );`

## Limitations

- This changes what is **stored**. Existing values are not rewritten — the filter only runs on new saves.- It runs after the field type’s own sanitisation, so do not rely on it for security. Sanitising happens first either way.- Returning nothing stores `null`. Every branch must return.

## Troubleshooting

### Old values still have the wrong format

The filter only runs on save. Run a one-off script over existing posts to normalise what is already stored.

### The value saved empty

A branch in the callback returns nothing. Check every path returns a value.

## Related Docs

- [Content Fields hooks reference](https://nexterwp.com/docs/nexter-fields-hooks-reference/)- [Template functions reference](https://nexterwp.com/docs/nexter-fields-template-functions/)