Support

Account

Home Forums General Issues How to update a Field when using Filter acf/update_value

Unread

How to update a Field when using Filter acf/update_value

  • update a field when using acf/update_value/ filter. I am updating a field via PHP. I can watch the update of this field and execute most code as expected however i am unable to update another field with ACF’s “update_field”.

    So the question is how can i watch a field change and change another depending on the watched fields value?

    Sample Code:

    add_filter(‘acf/update_value/name=my_field_name’, ‘my_awesome_function’, 10, 3);

    function my_awesome_function($value, $post_id, $field) {
    if ($value = ‘123’) {
    // UPDATE ANOTHER ACF FIELD HERE!
    update_field(‘another_field’, ‘new value’, $post_id);
    }
    return $value;

    }

Viewing 1 post (of 1 total)

The topic ‘How to update a Field when using Filter acf/update_value’ is closed to new replies.