ACF_Field_User::update_valuepublicACF 3.6.0

Filters the field value before it is saved into the database.

Method of the class: ACF_Field_User{}

No Hooks.

Returns

Mixed.

Usage

$ACF_Field_User = new ACF_Field_User();
$ACF_Field_User->update_value( $value, $post_id, $field );
$value(mixed) (required)
The field value.
$post_id(mixed) (required)
The post ID where the value is saved.
$field(array) (required)
The field array containing all settings.

Changelog

Since 3.6.0 Introduced.

ACF_Field_User::update_value() code ACF 6.0.4

function update_value( $value, $post_id, $field ) {

	// Bail early if no value.
	if ( empty( $value ) ) {
		return $value;
	}

	// Format array of values.
	// - ensure each value is an id.
	// - Parse each id as string for SQL LIKE queries.
	if ( acf_is_sequential_array( $value ) ) {
		$value = array_map( 'acf_idval', $value );
		$value = array_map( 'strval', $value );

		// Parse single value for id.
	} else {
		$value = acf_idval( $value );
	}

	// Return value.
	return $value;
}