Skip to content

Instantly share code, notes, and snippets.

@einkoro
Last active July 23, 2018 13:08
Show Gist options
  • Save einkoro/11078440 to your computer and use it in GitHub Desktop.
Save einkoro/11078440 to your computer and use it in GitHub Desktop.
Must-use plugin for WordPress to flush fields and post meta when using Advanced Custom Fields
<?php
/**
* Plugin Name: WP ACF Obj Cache Fix
* Plugin URI: http://bitpiston.com/
* Description: Fix for Advanced Custom Fields expiry with 3rd party Object Caches.
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.1.1
* Licence: BSD
*/
// Fix for Object Cache not flushing fields:
add_action( "acf/update_field", function( $field ) {
wp_cache_delete( 'load_field/key=' . $field['key'], 'acf' );
return $field;
}, 5, 1 );
// Flush post meta when saving a post:
add_action( "acf/save_post", function( $post_id ) {
wp_cache_delete( $post_id, 'post_meta' );
}, 20, 1 );
@einkoro
Copy link
Author

einkoro commented Jun 3, 2016

Both these issues appear to still exist under v5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment