I’m looking for the best solution to ensure that when ajax triggers gf render related filters like pre_render, field_render, etc, that a specific variable value can be exposed to the custom functions I have attached to these filters.
Here are a number of details about our solution:
- We have a custom block with a php callback script that renders the block
- The callback script renders some HTML that includes a gravity form which is ajax enabled and multi-page.
- There is a variable (cpt_id) whose value is only currently available to the callback script and is specific to each instance of the block.
- The block will only be added only once to any one page in the website
- We have a number of custom php functions that are called from various gravity form filters related to form rendering.
- All of these gravity form filter events are triggered after the block php callback script has run.
- The first filter event, gf_pre_render called (on page load) does have access to the variable that we put in a singleton
- Any singleton or global will fail following the initial page load and after the first triggered gf_pre_render filter
Our problem is to ensure that any of the functions associated with the gravity form render related filters can access the cpt_id value.
Singletons and globals will fail. We toyed with a hidden field as my assumption is that this is the nicest approach. However getting its default value in some filters is troublesome, although I assume possible. I’m starting to think that perhaps the wp_options table may be our best approach.
Just wondering if anyone could please offer what they would be looking at in this situation?
Any advice welcome.
Thanks