rwmb_value


目录

This filter is used to change a field value before saving it in the database.

apply_filters( 'rwmb_value', $value, $field, $old, $object_id );

It accepts 4 parameters:

Name Description
$value Field value which will be saved in the database
$field Field settings
$old The old meta value of the field (which was previously in the database)
$object_id The object ID

This filter has variations:

:::info If you return an empty string or an empty array (for cloneable fields or fields with multiple values like file, image, checkbox list), the field won't be saved in the database. :::

Examples

Disallowing a value from being saved:

add_filter( 'rwmb_event_date_value', function( $new, $field, $old, $object_id ) {
	if ( $new === '2022-05-01' ) { // No events on Labor Day
		$new = '';
	}
	return $new;
} );

版本号 #2
由 壳壳虫 创建于 2026-08-29 15:36:17 UTC
由 壳壳虫 更新于 2026-08-29 15:36:17 UTC