acf_rest_apply_user_data_sanitizer()
Reduces User field REST responses to IDs for requesters without the list_users capability. Hooked into acf/rest/format_value_for_rest so the sanitizer only runs for field types that can carry user data.
Хуков нет.
Возвращает
mixed.
Использование
acf_rest_apply_user_data_sanitizer( $value_formatted, $post_id, $field, $value, $format );
- $value_formatted(разное) (обязательный)
- The formatted field value.
- $post_id(строка|int) (обязательный)
- The post ID of the current object.
- $field(массив) (обязательный)
- The field array.
- $value(разное) (обязательный)
- The raw/unformatted value.
- $format(строка) (обязательный)
- The format applied to the field value.
Список изменений
| С версии 6.8.7 | Введена. |
Код acf_rest_apply_user_data_sanitizer() acf rest apply user data sanitizer ACF 6.8.8
function acf_rest_apply_user_data_sanitizer( $value_formatted, $post_id, $field, $value, $format ) {
if ( 'standard' !== $format || empty( $field['type'] ) ) {
return $value_formatted;
}
if ( ! in_array( $field['type'], array( 'user', 'group', 'clone', 'repeater', 'flexible_content' ), true ) ) {
return $value_formatted;
}
// Preserve existing behavior for requesters authorized to list users.
if ( current_user_can( 'list_users' ) ) {
return $value_formatted;
}
return acf_rest_sanitize_user_data( $value_formatted, $value, $field );
}