Home Forums ACF PRO Pruning Orphaned Flex-field Data Reply To: Pruning Orphaned Flex-field Data

  • What is the priority of your acf/save_post action?

    Also, I can’t be sure without seeing your action filter. The DB query to delete should be done before ACF inserts new data, so I can’t see why the deletion would continue while the update is being done.

    Also, you may need to clear the meta cache for the post after you do the query. Here is what happens when a field is updated, what WP does.

    First it does a query to see if the value is already in the DB. However, if the value is the the cache then it does not to the query and instead uses the value from the cache. If the new value and the old value are different then it does an update query, but if they are the same it may or may not do the update query (I have never been able to sort out why it sometimes does the update and other times does not).

    There may also be a case where all of the data will be deleted but nothing new will be saved. This could happen if you update a post without making any changes to ACF fields. There is a hidden field for ACF that is a flag indicating if anything was updated. If this flag is not set then ACF will not update values but and your acf/save_post action might not be called.