Home Forums General Issues function called before update_field


function called before update_field

  • 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 ?

  • This hook runs before update

    If you want to check before and after then you can use this hook, before or after depends on the priority of your action

  • 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…

  • 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.


  • What filter are you using? Post some code. I can’t help without more information.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.