Support » Plugin: Thumbs Rating » Hook for caching plugin

  • Resolved schotte

    (@schotte)


    Hi,

    we have just started using the plugin and it works great. There is just a problem in combination with our caching plugin (WP Fastest Cache).

    The cache obviously isn’t deleted/updated after the plugin receives a vote. Therefor the next visitors see just +5 votes for instance but after voting they see the votes are much higher (eg. +21).

    The caching plugin provides a hook/function for invalidating the cache of a page/post. Is there also a hook in the thumbs rating that is called with every vote received? Or could one be added?

    thanks
    Albert

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ricard Torres

    (@quicoto)

    Hey Albert,

    Good question, I don’t know.

    Do you have documentation on how these hooks work? How are they defined? How do you use them in the theme perhaps?

    If there’s an easy way for the plugin to call a hook and you do something on your side, we can do that.

    Thread Starter schotte

    (@schotte)

    Hi Ricard,

    WP Fastest Cache provides the wpfc_clear_post_cache_by_id( $id ) function to invalidate the cache of a specific post/page.

    We could call it from the themes function.php every time a vote is received by the plugin. There’ just an event/action-hook needed that is triggered by the thumb rating plugin every time the vote gets changed. I think you just have to integrate a do_action call after processing the vote and pass it an argument for post_id.

    See https://developer.wordpress.org/reference/functions/do_action/

    With this hook its possible to avoid similar problems when other caching plugins are used and there may even be some other ideas or interesting stuff that could be done.

    But if you know a better solution please let me know.

    thank in advance
    Albert

    • This reply was modified 9 months, 2 weeks ago by schotte.
    Plugin Author Ricard Torres

    (@quicoto)

    Hello @schotte

    Thank you for the info, I’ve pushed the 4.1.0 version with the action to be hooked from your theme.

    I’ve documented the name and parameters in the FAQ section: https://wordpress.org/plugins/thumbs-rating/#how%20do%20i%20run%20code%20whenever%20a%20user%20votes%3F

    Please test it and let me know how it goes.

    Cheers

    Thread Starter schotte

    (@schotte)

    Hey @quicoto,

    sorry didn’t realize there’s a new version until now. And it seems to work!

    Could invalidate the cache of the page that got the voting and got immediately the new page on another browser.

    Thank you very much for the fast reaction.

    Albert

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hook for caching plugin’ is closed to new replies.