Home Forums General Issues update_row() does not return true anymore?


update_row() does not return true anymore?

  • Hi all,

    After updating ACF Pro, it seems as if the function update_row() doesn’t return true or false anymore.
    I have the following simple code-snippet:

    $edit_update = update_row('field_5791d60e83186', $update_rij, $edit_row_data);
    if ($edit_update) {
    // do stuff if update_row() returns true
    } else {
    // show error if update_row() returns false

    Running the code does actually update the data of that row, but somehow the if statement is not reliable anymore because I don’t get a boolean true or false anymore.
    Anyone else having this issue?
    And if so, how to solve it?

  • Users can change content on the front-end, via a custom form, which will be updated by submitting the form.
    For now, after doing the update_row(), I compare the updated data with the data provided by the user. This works, but involves more code and I’m not happy with it.

  • I followed this through the functions. ACF update_row() ultimately returns what the last call returned by update_post_meta() or one of the other function that gets called in WP. In WP, if the current value is the same as the old value then update_post_meta() returns false.

    update_row() starts out by getting the value for the entire repeater and then replacing array for the one row and then updating the entire repeater field.

    Fields in ACF are updated by applying acf/update_value filters and in the case of a repeater all the sub fields are updated by a filter in ACF which returns the number of rows.

    The last thing that gets update by ACF is the meta field that holds the number of rows and since the number of rows is the same wp_update_meta() returns false.

    Anyway, I know that probably didn’t help you, but it explains why it always returns false, because the number of rows is not changed. I don’t know if this is a bug or not, and after spending time looking at it, I don’t know that there is any way to fix it. I’m pretty sure that update_value() on a repeater when you’re updating an entire repeater and it contains the same number of rows would have the same result.

    After looking, the only way I can see for you to know if a value is changed would be to loop through each sub field and use update_sub_field() on each, but I did not dig into that one.

  • Hi John,

    Thanks for the thorough reply.
    But the thing is, and according to the documentation (and thus the reason why I rely on it), that update_row() should return true or false based on success or failure of the function (
    And this used to work!

    After the latest update of ACF Pro, this is not the case anymore.
    I also submitted a support ticket, and I’ll expect a reply after the weekend.

  • I have reported this to the developer.

  • This will be corrected in the next version.

  • This reply has been marked as private.
  • I don’t know when the next version will be released other than “soon”, or at least I hope so.

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

The topic ‘update_row() does not return true anymore?’ is closed to new replies.