I have a site that allows user registration and login but not via the standard wp-login.php etc - it's all done within the theme and a bit of s2member as well.
I've been encountering problems where, with page caching enabled my code to show either a login button or a 'your account' button shows cached material.
I use the below do decide which button is shown depending on whether the right user level member is logged in.
<?php if (current_user_is("s2member_level1")) : ?> <?php $current_user = wp_get_current_user(); $redirect = '&redirect_to='.urlencode(wp_make_link_relative(get_option('siteurl'))); $uri = wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' ); ?> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown">My Account</a> <ul class="dropdown-menu"> <li><a href="<?= $uri; ?>">Logout</a></li> <li><a href="<?= get_permalink(x); ?>">Edit Account</a></li> </ul> </li> <?php else : ?> <li class="login-button"> <a class="btn-lg" href="<?= get_permalink(x); ?>">Member Login</a> </li> <?php endif; ?>
However with page caching enabled this has all sorts of problems.
I was looking at the Fragment Caching notes in W3TC's FAQ section but it looks like it has a major failing - it says:
Be aware that WordPress functions will not be available.
So, if I understand it correctly, that pretty much stops me from being able to use fragment caching.
As the member login/my account button is ever-present in the site main nav I've just disabled page caching entirely for the time being.
Is the only option for me to integrate some form of AJAX approach for handling dynamic sections dependent on auth/guest status?