Support » Plugin: W3 Total Cache » Login loop for returning subscribers?

  • Hi,

    I have set up a membership site using paidmembershipspro.

    I am having a login problem for subscribers, when they return to the site and login they are redirected back to the post they were on and it appears as if they are logged out. If they then click the login button they are looped to the same page with no change, if they click the register link they are shown the membership page as a logged in user, and if they then navigate to a protected post they get the same logged out view of the post. Refreshing the page in the browser fixes the problem, until they log out and then when logging back in the problem reappears…

    I have tried changing settings so the category and membership pages are never cached, and logged in users are not cached, and the role subscriber is not cached.

    When I deactivate W3 the problem goes away.

    Thanks

    • This topic was modified 4 years, 1 month ago by clayisland.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi here is an update:

    If I add the link to the post into the “Never cache the following pages” box the problem goes away.

    So how do I exclude all subscriber content, without adding each post link to the never cache list?

    I tried this:
    /category/nameofcategory/

    and it doesn’t seem to be working.

    Did you clear your page cache since it might be serving that up? If the old cache exists it will serve that. I tested the code for “Never cache” for something like /category/nameofcategory/ and it worked for me.

    Hi Kimberly,

    Thanks for the response.

    Yes I empty all caches when I make changes.

    I just tried disabling just the page cache and that eliminates the problem. Frustrating, not sure what else to try?

    Well I turned on debug and if I understand how W3 works I would need to change my permalink posts structure from this:
    http://www.mydomain.com/postname
    to something like this:
    http://www.mydomain.com/categoryname/postname

    and then adding /categoryname/ to the never cache list would exclude all posts in that category?

    Can someone confirm this is how W3 works? Or is there a simpler work around?

    Or how can I change the directory structure of just one category without messing up all my previously created permalinks?

    Ahh i see what you are trying to do now. Just to make sure….when navigating to “http://www.mydomain.com/categoryname/” you see a list of posts shown. It’s these posts that are shown that you want to not cache. Is that correct?

    I’ll have to do a little digging but i’m pretty sure the w3tc in its present form doesnt have that ability. Meaning, you can’t just put http://www.mydomain.com/categoryname/postname into the never cache list field since theoretically that url in the browser address bar leads to a 404 response (no page is returned).

    I could create a new field (of checkboxes) under Page Cache that allows one to select the category they want excluded (meaning: all posts that are listed under that category would not get cached). Right now i am just coding up regular expression support for several fields and will be incoporating the changes into the w3tc community build later tonight. After that i can have a look around if there is an alternate quicker solution for ya.

    In the mean time…

    Ahh i see what you are trying to do now. Just to make sure….when navigating to “http://www.mydomain.com/categoryname/” you see a list of posts shown. It’s these posts that are shown that you want to not cache. Is that correct?

    Yes, that’s exactly what I am trying to do. Or said another way I want to exclude a group of posts without having to enter the address for each one in the never cache list.

    Hi @clayisland. If you need a quick and dirty fix for the moment i just whipped up the following for ya that’ll hopefully work. By providing it a list of category slugs (replace “categoryname1”, “categoryname2”, etc with your real ones) it will check posts against this list. If a match is found no cache is made.

    You’d put this code into your theme’s functions.php file.

    
    add_action('wp_head','my_head_late',99);
    function my_head_late()
    {	
        $dont_cache_cats = array( "categoryname1", //Note these are the category slug names
                                  "categoryname2",
    			    );
    
        if (!is_admin())
        {			
            if (is_single())
            {
    	    if ($cats = get_the_category())
    	    {		
    	        foreach($cats as $cat)
    		{
    		    if (in_array($cat->slug,$dont_cache_cats))
    		    {
    		        if (!defined("DONOTCACHEPAGE"))
    			{
    			    define("DONOTCACHEPAGE",true);
    			    break;
    			}
    		    }
    		}
                }
            }
        }
    }

    I’ll create a new section in w3tc’s page cache admin area which will expand on this idea of categories by also allowing posts from being cached based on tags, custom fields, or author. Maybe tomorrow or the next day i can have it committed to the community-driven build.

    Cheers
    Kimberly

    • This reply was modified 4 years, 1 month ago by Kimberly.
    • This reply was modified 4 years, 1 month ago by Kimberly.
    • This reply was modified 4 years, 1 month ago by Kimberly.
    • This reply was modified 4 years, 1 month ago by Kimberly.

    Good Morning,

    You are the best Kimberly!

    That works great. The debug now says this:

    
    Caching:            disabled
    Reject reason:      DONOTCACHEPAGE constant is defined
    Creation Time:      0.413s
    

    Cheers,
    Clay

    • This reply was modified 4 years, 1 month ago by clayisland.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Login loop for returning subscribers?’ is closed to new replies.