acf_bindings_reduce_user_value() │ ACF 6.8.11

Reduces a formatted User field value to user IDs.

User arrays and objects become integer IDs. Scalar values, such as IDs or text that a format_value filter has already produced, are left as they are, so numeric-looking text such as '007' isn't cast to an integer.

Хуков нет.

Возвращает

mixed.

Использование

acf_bindings_reduce_user_value( $value, $field );
$value(разное) (обязательный)
The formatted User field value.
$field(массив) (обязательный)
The field array.

Список изменений

С версии 6.8.11 Введена.

Код acf_bindings_reduce_user_value() ACF 6.8.11

function acf_bindings_reduce_user_value( $value, $field ) {
	$to_id = static function ( $user ) {
		return ( is_array( $user ) || is_object( $user ) ) ? acf_idval( $user ) : $user;
	};

	if ( ! empty( $field['multiple'] ) && is_array( $value ) ) {
		return array_map( $to_id, $value );
	}

	return $value ? $to_id( $value ) : $value;
}