Hi, I’m trying to use the update_value filter with an image field to fire when a new image is uploaded. When I compare $value and $old_value (the 1st and 4th parameters), they are always the same — the new value.
I’ve tried setting the filter priority to above and below 10, and nothing seems to change.
In this case the “Old Value” is not the value from the DB. Old value would only be different than New Value after another update_value filter change the value. Here Old value means the value that was submitted vs what the value currently is. These will always be the same unless your site has multiple filters that are operating on the field.
If you want to compare the old value in the DB vs the new value submitted then you need to use an acf/save_post action with a priority < 10. $_POST[‘acf’][$field_key] will hold the new value (an ID) and to get the old value you can use get_field('field', $post_id, false) which will always return the image ID.