Home Forums Bug Reports acf/update_value filters working improperly Reply To: acf/update_value filters working improperly

  • So, the way ACF works is that its internal functions are called using the same hooks provided for us. ACF has an internal filter/method, usually inside of the class for each field type, that runs when it calls acf/update_value. All ACF internal filters run on the default priority of 10.

    At the point where this filter is called the original value is the same as the value that’s it’s passing when the hook is run. This will always be the case at this point in the code.

    When it comes to ACF’s internal update value filters it does not look at or consider if the value has already been modified. This can be confirmed by looking at any update_value() method in any of the field classes. This may be something that will happen in the future, but it is not yet the case. It may very will be some improvement that is being worked on because until this topic I did not know that it passed the original value and it is not documented here

    So, right now, if your filter runs before ACF’s internal filter then the value and the orginal value will be the same.

    So, here’s the thing. If you do not give your filter a priority that means that both your filter and ACF’s internal filter will have the same default priority of 10 and in this case there is almost no way of knowing which one of these filters will run first. It depends on the order that they are added and other things. You’re best bet when adding a filter in ACF is to always use a priority > 10 if you want to ensure that it runs after ACF’s internal filters.