Jhon Doe Photo

MARKO JAKIĆ

software engineer / web developer

Download vCard
  • Fix W3TC Logout Issue

    Posted by markzero on Friday, June 10th, 2011

    WordPress plugin W3 Total Cache sometimes has issue with site’s log in/out. Most probable reason for this is caching the old page of course, where we still see logout button after pressing it, but we are actually logged out. That you can check by going to /wp-admin of your blog/site. For me, this happened on my WP E-Commerce powered site – just a mention.

    Here’s what I did: combined WordPress wp_logout action and w3tc_pgcache_flush function, which runs when you delete page cache. It’s clearly written on W3TC docs.

    Full code looks like this:

     
    <?php
    add_action('wp_logout', 'mj_flush_w3tc_cache');
    function mj_flush_w3tc_cache()
    {
        if (function_exists('w3tc_pgcache_flush')) {
            w3tc_pgcache_flush();
        }
    }
    ?>

    Put it into your functions.php file. Of course, you can rename mj_flush_w3tc_cache function to whatever you like…

    Tweet

    Posted in: PHP, Wordpress.

    Share this story:

    Share 'Fix W3TC Logout Issue' on Bebo Share 'Fix W3TC Logout Issue' on Blogger Share 'Fix W3TC Logout Issue' on Delicious Share 'Fix W3TC Logout Issue' on Digg Share 'Fix W3TC Logout Issue' on Fark Share 'Fix W3TC Logout Issue' on Google Bookmarks Share 'Fix W3TC Logout Issue' on LinkedIn Share 'Fix W3TC Logout Issue' on Mixx Share 'Fix W3TC Logout Issue' on Newsvine Share 'Fix W3TC Logout Issue' on reddit Share 'Fix W3TC Logout Issue' on Spurl Share 'Fix W3TC Logout Issue' on Squidoo Share 'Fix W3TC Logout Issue' on StumbleUpon Share 'Fix W3TC Logout Issue' on Yahoo! Buzz Share 'Fix W3TC Logout Issue' on Email

    7 Responses to “Fix W3TC Logout Issue”

    1. rimon says:
      June 26, 2011 at 11:52 pm

      thanks markzero..I’ve spend a whole night to fix it..but i failed. Thanks a lot for giving such a great solution

      Report this comment

      Reply
    2. markzero says:
      June 27, 2011 at 8:59 am

      Glad it helped rimon :) helped me too! On my wp ecommerce site

      Report this comment

      Reply
    3. Eric Andrew Lewis says:
      May 1, 2012 at 4:13 pm

      Is this a scalable solution to this issue? Flushing the page cache every time a user logs out?

      Report this comment

      Reply
    4. markzero says:
      May 2, 2012 at 8:38 am

      Not sure about scalability Eric, but why not. It works. Don’t think it’s as common operation, w3tc does it’s job for logged users and guests which is quite enough for me

      Report this comment

      Reply
    5. Aron says:
      May 6, 2012 at 5:50 am

      Thanks for the fix ;) Used in this site :)
      Still works people, use it !

      Cheers,
      Aron

      Report this comment

      Reply
    6. Rashid says:
      September 6, 2012 at 5:10 pm

      Hey Mark,

      I am facing an issue which is opposite compared to yours. I am logged in via wp-admin but on the main site I am logged out.

      Any help will be deeply appreciated.

      Thanks,
      Rashid

      Report this comment

      Reply
    7. Lars says:
      October 22, 2012 at 11:52 am

      FAT Thanks for this amasing Bug Fix!
      Absolut great work! I try a lot but without success! Now all works fine, the Logout too :D

      Many Greetz,
      Lars

      Report this comment

      Reply

    Leave a Reply

    Click here to cancel reply.

    • Useful Links

      • Image Resizer Online Tool
      • Image Rotator Online Tool
      • MJ Posts Extras
      • MJ Quick Comments
      • MJSlider
      • Random Text Paste
    • Categories

      • CSS
      • DOM
      • Javascript
      • JQuery
      • Linux
      • Magento
      • MySQL
      • PEAR
      • PHP
      • PHPUnit
      • Prototype JS
      • Ruby
      • SQL
      • Tech
      • Ubuntu
      • Wordpress
      • XML
      • YouTube

    Archives

    • July 2012
    • June 2012
    • April 2012
    • December 2011
    • November 2011
    • October 2011
    • September 2011
  • HOME