I regularly use Advanced Custom Fields to create awesome backend interfaces for my clients (as I’m sure a lot of us do…). ACF includes an Options add-on that creates one or multiple global options pages that one can pull data from anywhere. I use the Options page to, for example, let the client select the 5 posts to be featured on a homepage carousel.
I have started running into issues using the Options add-on and Super Cache. It seems that by default saving the Options page has no effect on the cache and so for example the homepage carousel remains unchanged and the client is confused…
I need to hook into the Options page to programmatically empty the cache when the Options page is saved, as I do not usually give my clients Admin access or bother them with technical things like caches.
The author of ACF says the following:
There is an action called acf/save_post which is used to save all the posted field data. Perhaps you could use this action to hook into and flush the cache.
You could use the $post_id parameter to decide whether it is an options page or not. I believe the options page will pass through ‘0’ as the post_id. Either that or ‘options’.
Is anyone able to help with creating an action that would completely clear the Super Cache cache every time the Options page is saved. This would no doubt help a lot of people!
acf/save_post info here: http://www.advancedcustomfields.com/resources/actions/acfsave_post/
Thanks so much in advance.
This function will clear WP Super Cache upon saving of ACF Options page. Enjoy!