acf_bindings_should_reduce_user_data()
Checks whether a User field's value should be reduced to user IDs before it is output by the [acf] shortcode or an ACF block binding.
Both render into pages that anyone can view, so unlike the REST API this isn't gated on a capability. Only User fields are handled: field types that can contain a User field, such as Group and Clone, can't be output through bindings, and acf_bindings_flatten_value() outputs nothing for the nested arrays they'd produce.
Хуки из функции
Возвращает
boolean.
Использование
acf_bindings_should_reduce_user_data( $field, $post_id, $context );
- $field(массив|false) (обязательный)
- The field array.
- $post_id(int|строка) (обязательный)
- The ACF post ID the value is loaded from.
- $context(строка) (обязательный)
- Where the value is output. Either
'shortcode'or'bindings'.
Список изменений
| С версии 6.8.11 | Введена. |
Код acf_bindings_should_reduce_user_data() acf bindings should reduce user data ACF 6.8.11
function acf_bindings_should_reduce_user_data( $field, $post_id, $context ) {
if ( ! is_array( $field ) || empty( $field['type'] ) || 'user' !== $field['type'] ) {
return false;
}
/**
* Filters whether the [acf] shortcode and ACF block bindings may output full User field data.
*
* By default, User field values are reduced to user IDs, so personal data such as
* email addresses isn't displayed to visitors. Returning true skips that reduction.
* Only values that can be output as text are displayed, so a single User field
* returning an array outputs its data as a comma separated list, but multiple users
* returned as arrays or objects still output nothing.
*
* @since 6.8.11
*
* @param boolean $allow Whether to output full User field data. Default false.
* @param array $field The field array.
* @param integer|string $post_id The ACF post ID the value is loaded from.
* @param string $context Where the value is output. Either 'shortcode' or 'bindings'.
*/
return ! apply_filters( 'acf/bindings/allow_user_data', false, $field, $post_id, $context );
}