Overview
Control whether ACF treats the current save as trusted, skipping user permission checks on submitted values.
Description
When ACF saves values submitted through a form or the REST API, it checks that the current user can make two kinds of change: adding a reference to the other side of a bidirectional field, and selecting a new post in a Relationship, Post Object, or Page Link field. Saves from a trusted context, where values come from code rather than a request, skip these checks. Other protections, such as nonces, validation, and the fields a form is allowed to save, aren’t affected.
By default, ACF treats WP-CLI commands and cron jobs as trusted. Use this filter to mark other server-side saves as trusted, such as a custom import that calls acf_save_post().
Parameters
apply_filters( 'acf/is_trusted_save_context', $trusted );
$trusted
(bool) Whether the current save is trusted. Default: true for WP-CLI and cron, otherwise false
Example
Trust saves made during a custom import
add_filter( 'acf/is_trusted_save_context', function ( $trusted ) {
if ( doing_action( 'my_plugin_run_import' ) ) {
return true;
}
return $trusted;
} );
Changelog
- Added in version 6.8.11
Notes
- Never return
truefor saves that include values submitted by users, such as front-end forms or REST API requests. Doing so removes the permission checks that protect other content on your site. - Values saved with update_field() and ACF’s other value functions, such as update_sub_field(), add_row(), and update_row(), aren’t permission checked, even during a submitted save. You don’t need this filter for them.
Supercharge Your Website With Premium Features Using ACF PRO
Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.
Related
- Filters: acf/bidirectional/can_update_target
- Filters: acf/fields/allow_append_choices
- Filters: acf/form/{context}/allowed_field_keys
- Filters: acf/settings/enable_datastore
- Filters: acf/update_value