Home Forums Add-ons Repeater Field Repeater fields only update after twice clicks on update button


Repeater fields only update after twice clicks on update button

  • Hello there,

    I’m facing a strange situation. I have a cpt firing a save_post action to update some data. This cpt has a repeater field with some “regular fields”.

    This repeater just update the data (add a new element inside the array) if I click twice on the Publish/Update button. On the first click, the data is stored inside of this ctp but I cannot get the values from the repeater updated.

    Here a code example:

    function auto_ctp($post_id, $post, $update) {
      $fields = get_fields($post_id);
      // Here, the var is empty on the first click
      // but filled on the update or on the second click
      if (wp_is_post_revision($post_id)) {
      else {
        remove_action('save_post_ctp', 'auto_ctp');
        // execute some update code
        // load the action again
        add_action('save_post_ctp', 'auto_ctp', 10, 3);
    add_action('save_post_ctp', 'auto_ctp', 10, 3);

    I’m sure that I missed some hook to get the full data but, after a search on the documentation, I didn’t see anything that helps me.

    Any idea where is the mistake on this logic?

    Thanks a lot

  • when this hook fires save_post_ctp ACF has not yet saved data. This hook is fired before ACF saves anything. You need to use the acf/save_post hook or you need to use the WP “save_post” hook with a priority > 10.

    If you want to get data before ACF has saved values then you need to look in $_POST['acf']

  • Gotcha!
    The acf/save_post solved my problem.

    Thanks a lot!

Viewing 3 posts - 1 through 3 (of 3 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.