WordPress.org

Ready to get started?Download WordPress

Forums

Compatibility with Simple Forum (16 posts)

  1. GrantBarrett
    Member
    Posted 6 years ago #

    I now use the outstanding Simple Forum. With WP-Super-Cache installed, however, a side effect is that when new topics or comments are posted to SF, the cache isn’t cleared so that those new topics or comments will show up. Instead, they have to wait until the cache is cleared automatically. Is there a way to make SF clear the cache when new topics and comments are posted? Some hook or something that I can add to its URLs that will call WP-Super-Cache and make it do that?

  2. Donncha O Caoimh
    Member
    Posted 6 years ago #

    If an action executes when forum posts are made and if the cache plugin is loaded then you could add a hook onto it that calls the prune cache function.

  3. GrantBarrett
    Member
    Posted 6 years ago #

    I'm sorry, Donncha, but that's a bit beyond my ken. I'll keep looking into it, but if you could point me to documentation or an example of how do_cacheaction() and add_cacheaction() have been used to solve this problem for other plugins, it would be very helpful.

  4. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Look in wp-cache-phase2.php for the section of code with multiple add_action() calls:
    add_action('publish_post', 'wp_cache_post_change', 0);
    add_action('edit_post', 'wp_cache_post_change', 0);
    ...
    add_action('switch_theme', 'wp_cache_no_postid', 0);

    Look through the simple forums documentation or source, and hopefully you'll find an action you can call 'wp_cache_no_postid' on. For example, if it's called 'simple_forums_post' then the action is:

    add_action( 'simple_forums_post', 'wp_cache_no_postid' );

  5. GrantBarrett
    Member
    Posted 6 years ago #

    So, this gets me somewhere. Simple Forum has two functions that I believe are what we want, sf_save_topic and sf_save_post. Therefore, I would add these lines:

    add_action( 'sf_save_topic', 'wp_cache_no_postid' );
    add_action( 'sf_save_post', 'wp_cache_no_postid' );

    to wp-cache-phase2.php, right? And that would mean that when those two functions are called, then the cache is cleared?

  6. GrantBarrett
    Member
    Posted 6 years ago #

    By the way, I opened a conversation with the creator of Simple Forum, too. But I think it might take all three of us to get there...

  7. GrantBarrett
    Member
    Posted 6 years ago #

    Well, I tried adding those two lines to wp-cache-phase2.php but it doesn't flush the cache when creating a new topic.

  8. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Instead of adding them in wp-cache-phase2.php, create a new file in the wp-super-cache/plugins/ folder (call it 'simpleforum.php') and put something like the following there:

    function simpleforum_phase2_actions() {
        add_action( 'sf_save_topic', 'wp_cache_no_postid' );
        add_action( 'sf_save_post', 'wp_cache_no_postid' );
    }
    add_cacheaction( 'add_cacheaction', 'simpleforum_phase2_actions' );

    That way you can upgrade the plugin without worrying about overwriting your changes.
    You could also create a new function in that file that calls the 'prune_super_cache' function.

    Once you get it working, maybe it'll get shipped with Simple Forum? :)

  9. GrantBarrett
    Member
    Posted 6 years ago #

    Thanks, donncha. What's the difference between wp_cache_no_postid and prune_super_cache? And is "simpleforum.php" now supposed to show up in the WP Super Cache admin screen, down at the bottom with the cache plugins?

  10. Donncha O Caoimh
    Member
    Posted 6 years ago #

    wp_cache_no_postid only deletes wp-cache files while the prune function clears out all files in your cache directory.

    Yes, the simpleforum plugin should appear at the bottom of your admin screen

  11. GrantBarrett
    Member
    Posted 6 years ago #

    Hmmm, it doesn't appear at the bottom of the WP Super Cache admin screen. At first I stoopitly forgot to wrap it in PHP tags, so it showed up at the top of the screen. After I added them, still nada. Looking at the searchengine.php file, I suspect that more is required than merely copying your code above and wrapping it in PHP tags.

  12. GrantBarrett
    Member
    Posted 6 years ago #

    Donncha, I wonder if you had any more thoughts on this. What you've given so far seems tantalizing, but there's not enough information here for me to put it to work.

  13. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Email me at donncha @ ocaoimh.ie - I need to see your script to know what's going wrong.

  14. olivers
    Member
    Posted 6 years ago #

    Hi donncha et al!

    As part of a bigger upgrade I'm trying to do the exact same thing. Has this been resolved, is it working as suggested above?

    Thank you!
    Oliver

  15. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Oliver - unfortunately not.

  16. olivers
    Member
    Posted 6 years ago #

    I'm happy to give it another shot, since I need this to work and can't imagine it, with the above jump-start, to be that difficult. I also know Andy, the author of SimpleForum, so between the three of us it should be quite doable.

Topic Closed

This topic has been closed to new replies.

About this Topic