Support

Account

Home Forums General Issues Flush Unused Custom Fields

Solved

Flush Unused Custom Fields

  • I’ve noticed that if you change existing fields, it can sometimes break entire field groups in a difficult-to-reproduce way. I feel like having a way to flush old fields would fix this. +1 for this still being on the roadmap! <3 @elliot

  • Why is this issue marked as “solved”? Let’s keep this thread alive people, this is an important feature @elliot

  • +1000 for this feature request! I recently had issues with a client’s search form that uses custom field data that was broken because it was using an old custom field structure that was no longer in place, and I had no idea that was an issue. Please please add this feature soon!

  • +1000 for this feature request! I recently had issues with a client’s search form that uses custom field data that was broken because it was using an old custom field structure that was no longer in place, and I had no idea that was an issue. Please please add this feature soon!

  • This is NOT SOLVED

    please we NEED this important feature

    I’m a PRO customer, and I think we deserve this feature

  • +1 Even if it’s just a partial solution, a roadmap for deleting old unused fields would be super helpful.

  • An imperative feature!
    +1

  • Hi,
    try this plugin i just made:

    https://github.com/filippozanardo/redvolver-cleanacf

    Don’t use in production yet.
    Feel free to post comment or pull request.

    Cheers

  • So it says “Solved” at the top. Can anyone point to the documentation that solves this?

  • @estevancarlos your right, not solved.. and its only been 3+ years

  • +1

    This really does need an official solution.

    I’ve just tested https://github.com/jameswburke/acf-cleaner on a local site and it’s definitely NOT a good solution!
    The deletion process is very tedious and it doesn’t seem to play well with flexible content fields, marking mine as empty even though most of the site is made up of them! Oh well… the wait continues!

  • Try mine https://github.com/filippozanardo/redvolver-cleanacf works well as far as i test work on save i will make a bacth process when i have time.
    Let me know

  • Hi Eliot,
    Why is not official plugin or feature to cleanup this automatically?

  • A little while later and i take back my original assessment of https://github.com/jameswburke/acf-cleaner

    It does flag up some items that are still in use (it doesn’t seem to get along with flexible content fields) but if you take care with your field names (and so know which ones are still in use) this seems to be the best solution for now.

    You have to delete ONE at a time, and wait for a refresh of the screen which is tedious and if you manually install you need to rename the plugin folder to just “acf-cleaner” or it fails to load the script it needs to work. But with no official solution, this at least works!

  • Pulsecode,
    if you need an automate solution try my plugin scan on every acf post save for unused acf or you can complete delete all before save and “resave” the field.

    Still need some work but as far as i test works, you can also open a issue on github to improve it.
    Works at the moment only on post and custom post type not on the taxonomy but when i have time i will improve the feature.

    https://github.com/filippozanardo/redvolver-cleanacf

  • Hi redvolver,

    In the case of the site i was working on, it had over 400 pages that had been experimented on by the user, so having to to through and save every single page was not something i wanted to have to do.

    I’ll try it out on something less huge though :^)

  • This is definitely not solved and need a fix in core or at least a (hidden) option for advanced users.

  • I have been looking into a way to do this.

    Before I get into how this can be done, with some problems, I just want to point out that doing this the way that most people would expect it to be done is nearly impossible. If you know anything about the way ACF and WP work, and you’ve looked into this you’ll quickly come to the same conclusion.

    Sometimes “impossible” just means very difficult, but in this case it really does mean impossible. WP has limits to what it can do and attempting to have ACF clean up all unused values when they are no longer needed would run into these limits imposed by the way that WP is built. In almost all cases it would simply cause the saving and updating to time out and not complete.

    I would love to hear from people that use other custom field plugins an know if any of them clean up after themselves the way people want ACF to clean up after itself. I’d look myself, but I have no interest in these other plugins or seeing what happens with unused data.

    I’ve actually started trying to explain why it is impossible several times and failed. Trying to think about what needs to be done to have this automatically happen under every condition nearly makes my head explode.

    There is only one way I can think of that this can be done, and even it cannot be made to work under all conditions. That way is to delete all existing data before ACF updates the fields, or to just wholesale delete all content whenever an ACF field is deleted.

    The condition where this will not work is altering the location rules of a field group. If a field group is located on posts and you change the location to pages, there simply isn’t any easy way to then remove all of the field values from all of the posts that were already saved. Not without checking every object in WP to discover what objects the fields should not be saved for.

    There is also a condition that will cause data that you don’t want deleted to be deleted anyway. This condition will happen with cloned fields and in any other place where a field key is duplicated.

    There is also the case of someone deleting fields when the goal is to keep the field data because you want to move the fields into PHP and remove the field group from the ACF admin.

    I’ve actually started building a plugin that will do this, but I hesitate do complete it and make it publicly available because there are cases were, if used improperly, people will end up having content deleted that they do not want deleted and hold me responsible for messing up their site. While I know it will work if used properly, I’m afraid that there are probably too ways that it could be used improperly.

Viewing 25 posts - 26 through 50 (of 100 total)

The topic ‘Flush Unused Custom Fields’ is closed to new replies.

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.