Hello,
I’d like to know if there’s a hook that i called before update_field is triggered…
I’m using a plugin that let the me display acf forms on frontend.
This means users can edit the data, and also the meta associated. *
But I need to do some stuff, and for that I need to checl the value of the meta before and after.
Could you please help me ?
Thanks.
Regards
This hook runs before update https://www.advancedcustomfields.com/resources/acf-update_value/
If you want to check before and after then you can use this hook, before or after depends on the priority of your action https://www.advancedcustomfields.com/resources/acf-save_post/
Hello,
Thanks but it’s not working…
I’m not able to get the actual value of the field, I just have the value updated…
Regards,
What filter are you trying?
If you use acf/update_value then $value will be the new value and the old value will be in the DB.
If you use acf/save_post with a priority of <10 then the old value is in the DB and the new value is in $_POST[‘acf’][$field_key]
ACF does not have the old value, nor care what it is, when saving. ACF will never have the old value when updating a field.
Hello,
Thanks for your answer, I think it will be ok.
Just one question :
How get I get the field_key from the field_name ?
For example I do this :
$current_status = get_field('status', $post_id);
to retrieve the current value, beofre save.
But to get the posted value I have to first get the key of this “status” field.
Thanks
Regards
What filter are you using? Post some code. I can’t help without more information.