Support » Fixing WordPress » Compatibility with Simple Forum

  • 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?

Viewing 15 replies - 1 through 15 (of 15 total)
  • 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.

    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.

    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’ );

    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?

    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…

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

    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? 🙂

    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?

    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

    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.

    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.

    Email me at donncha @ – I need to see your script to know what’s going wrong.

    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 – unfortunately not.

    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.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Compatibility with Simple Forum’ is closed to new replies.