How to bypass cached results?
-
PROBLEM
I have a special case where I’m outputting a bit of custom HTML after each item in a group field. For this I’m using a customafter_group_row
callback function. My callback function works with one exception: the dynamic values that I’m trying to output as part of the HTML string are cached by CMB2, so only the values for Row 1 are returned for all rows.Here is a gist showing my metabox and callback function.
HACKY SOLUTION
Looking at the CMB2 changelog I found theunset_param_callback_cache()
function. If I hack the CMB2 source fileCMB2.php
to add this line
$field_group->unset_param_callback_cache( 'after_group_row' );
at the top of therender_group_row()
function definition (starting about line 594), it works and my callback returns fresh values.Of course, I’d rather not modify the CMB2 plugin files if I can help it. Is there a way to leverage
unset_param_callback_cache()
without messing with core files? Or perhaps another method of bypassing the cache?
- The topic ‘How to bypass cached results?’ is closed to new replies.