-
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…
Share this story:
7 Responses to “Fix W3TC Logout Issue”
Leave a Reply
Useful Links
Categories
Archives















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
Glad it helped rimon
helped me too! On my wp ecommerce site
Report this comment
Is this a scalable solution to this issue? Flushing the page cache every time a user logs out?
Report this comment
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
Thanks for the fix
Used in this site 
Still works people, use it !
Cheers,
Aron
Report this comment
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
FAT Thanks for this amasing Bug Fix!
Absolut great work! I try a lot but without success! Now all works fine, the Logout too
Many Greetz,
Lars
Report this comment