acf/bidirectional/can_update_target

Last updated Nov 2, 2026

Overview

Control whether a bidirectional field can update the other side of a relationship.

Description

When a bidirectional field is saved, ACF also updates the field on the other side of the relationship. When values are submitted through a form or the REST API, ACF checks that the current user can update the other side before adding a reference:

  • Posts: the user must be able to edit the post.
  • Terms: the user must be able to assign the term.
  • Users: the user must be able to edit the user, or be able to edit other people’s posts of the origin post’s type, as they could already set that user as the post’s author. On multisite, this only applies to members of the current site who aren’t Super Admins, and users who can promote users, such as site administrators, can also link members of their site.

If the check fails, the value still saves on the object being edited, but the other side isn’t updated. Removing a reference isn’t permission checked. Values saved with update_field(), or from a trusted context such as WP-CLI or cron, aren’t checked.

Use this filter to allow or prevent updates to the other side, for example on a front-end form where visitors are meant to create bidirectional links.

Parameters

apply_filters( 'acf/bidirectional/can_update_target', $can_update, $target_id, $post_id, $field, $action );

$can_update (bool) Whether the other side can be updated. Always false for targets that don’t exist.

$target_id (int|string) The ACF post ID of the object on the other side, such as 123, user_5, or term_12.

$post_id (int|string) The ACF post ID of the object being saved.

$field (array) The field being saved.

$action (string) Either 'add' or 'remove'.

Example

Allow a specific field to update the other side

add_filter( 'acf/bidirectional/can_update_target', function ( $can_update, $target_id, $post_id, $field, $action ) {
    // related_events links to posts, so $target_id is a post ID. Check it exists before allowing the update.
    if ( 'related_events' === $field['name'] && get_post( (int) $target_id ) ) {
        return true;
    }
    return $can_update;
}, 10, 5 );

Changelog

  • Added in version 6.8.11

Notes

  • Scope this filter to specific fields rather than returning true for every field.
  • Only return true for targets that exist. If you return true for a target that doesn’t exist, ACF saves the reference anyway, and a post, user, or term created later with that ID inherits it. For User and Taxonomy fields, check the target with get_userdata() or get_term().
  • If a link was only saved on one side because the user couldn’t update the other side, it’s added the next time someone who can update the other side saves the object.
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.

Explore Features View Pricing

PRO Features
ACF Blocks
Options Pages
PRO Fields
Repeater
Flexible Content
Gallery
Clone

Related