• Resolved Tuempelkoenig

    (@tuempelkoenig)


    Hi,

    Assuming I have the plugins JS and Forma Cache enabled: Is there a filter I could use to define if the js/forms are served from the cache or not?

    Some of my users need to get the forms from the cache and some do not. I was hoping that I could apply a specific body class to each page according to the users role and then use a filter to decide if your plugin uses the cache or not.

    • This topic was modified 3 years, 6 months ago by Tuempelkoenig.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @tuempelkoenig

    Our plugin renders the forms on the client-side. If you enable the form’s cache option, the plugin loads a rendered version of the form. This option does not affect the fields’ values or form information, only the way it is generated.

    Best regards.

    Thread Starter Tuempelkoenig

    (@tuempelkoenig)

    I am aware of that. In my case, I have some restricted contend (I use the restrict content pro plugin) my users need to pay for. There is also a free account, where a user is allowed to view 4 posts per month for free (https://github.com/dkjensen/restrict-content-pro-view-limits). If I enable your plugins cache, the counting of viewed pages does not work correctly. Therefore I was looking to disable the cache for those users. Any idea?

    Plugin Author codepeople

    (@codepeople)

    Hello @tuempelkoenig

    The form’s cache is not a general cache. It does not affect the content managed by other plugins. The form’s cache does not affect the number of posts or pages visited by the users.

    Best regards.

    Thread Starter Tuempelkoenig

    (@tuempelkoenig)

    I know it should not. But somehow it still affects it (only some of my posts are counted twice) if the cache is enabled.

    As I can’t figure out what is happening exactly, I was hoping to control the cache on a per user role basis. Is there such a filter to enable/disable the cache?

    Plugin Author codepeople

    (@codepeople)

    Hello @tuempelkoenig

    You can disable the option for caching the forms from the settings page of our plugin, without affecting the forms.

    Best regards.

    Thread Starter Tuempelkoenig

    (@tuempelkoenig)

    Yes, for all forms. But is there a WP hook (filter) for the cache to enable/disable it?

    Something like
    define( ‘CFF_CACHE’, false );

    • This reply was modified 3 years, 6 months ago by Tuempelkoenig.
    Plugin Author codepeople

    (@codepeople)

    Hello @tuempelkoenig

    No, the plugin does not manage the forms cache by form. It does it globally.

    Best regards.

    Thread Starter Tuempelkoenig

    (@tuempelkoenig)

    Yes, I understand that. But I am asking if there is a hook (not only the checkbox in the settings) to enable/disable it globally?

    Something like
    define( ‘CFF_CACHE’, false );

    • This reply was modified 3 years, 6 months ago by Tuempelkoenig.
    Plugin Author codepeople

    (@codepeople)

    Hello @tuempelkoenig

    If you want to manage it by filters, you can use the WordPress filters.

    add_filter("option_CP_CALCULATEDFIELDSF_FORM_CACHE", function($v, $o){return false}, 10, 2);

    Best regards.

    Thread Starter Tuempelkoenig

    (@tuempelkoenig)

    That did the trick, thanks!

    For those looking for a solution: there is a missing ; after return false.

    Plugin Author codepeople

    (@codepeople)

    Hello @tuempelkoenig

    Yes, I’m sorry, I forgot the semicolon:

    add_filter("option_CP_CALCULATEDFIELDSF_FORM_CACHE", function($v, $o){return false;}, 10, 2);

    Best regards.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Filter for JS&Form Cache’ is closed to new replies.