Pro Sites - Caching

There are a number of caching instances in the Pro Sites' code. These check if the user is a pro sites user (1 hour), or if the site is a pro site (3 hours) ... as well as extensions, free trials, and so on.

I would like to shorten these time periods. Can someone please help me understand why the plugin caches, and how changing it will affect my MU install? Will it put a strain on the server? Is there a ratio of caching to subsites/pages/posts that I could implement.

I assume these caching instances were included because Edublogs has 1+ million subsites. For my MU install, I anticipate < 1,000 subsites. How does that affect my decision to reduce the amount of time caching?

Thanks,
Chris

  • Aaron

    The caching is persistent object caching, so it's of no note to you.
    Example when a value is changed, like pro status changes or similar, we update the cache as well. It doesn't introduce any delays, just lowers db load if you have a persistent object cache installed (memcached, etc).

    The only exception is the is_pro_user(), but we don't really use that in the plugin at all or recommend it's use in third party scripts.

  • Chris

    Hi Aaron,

    I am using is_pro_user() to restrict content on my website. When a member upgrades his/her site, they are provided with access. However, there is a three hour delay, which is the reason I am concerned about caching. Is there a way I can get around this?

    Thanks,
    Chris

    function prosites_hide_buddypress_uri() {
    
    	$userid = get_current_user_id();
    	$uri = $_SERVER['REQUEST_URI'];
    	$not_allowed = array("/^\/members\/$/", "/friends\/*/", "/^\/groups\/*/", "/^\/forums\/*/", "/\/groups\/create\//", "/\/site-tracking\/create\//", "/\/members\/[^\/]*\/groups\//", "/\/members\/[^\/]*\/forums\//", "/\/members\/[^\/]*\/settings\//");
    
    if (!is_pro_user($userid) ) {
    
    		foreach($not_allowed as $check)
    		{
    		if(preg_match($check, $uri))
    		{
    			wp_redirect(home_url("/upgrade/"));
    			exit;
    		}
    	}
    
    }else{
    
    }
    }
    
    add_action("init", "prosites_hide_buddypress_uri");
  • Chris

    Hi Aaron,

    The above function is no longer working. I will paste it below again. Can you see anything in the code that would make it stop working?

    Here's the test I ran -
    1 - I created a new website. The user didn't have access to the uri's below.
    2 - I upgraded to Pro status. User has access to uri's.
    3 - I went into the database and changed the 'expire' field to 10/9/2014 (1412816461). User still has access, even though the expiration time is past.

    This should return the user as not a pro_user, correct? However, the user still has access to the uri's.

    UPDATE: It finally restricted the user and hour later, which is what the caching is set to. However, I thought by changing expire to more than 1 hour past, it would automatically expire the account. What am I not understanding here?

    Thanks,
    Chris

    function prosites_hide_buddypress_uri() {
    
    	$userid = get_current_user_id();
    	$uri = $_SERVER['REQUEST_URI'];
    	$not_allowed = array("/^\/members\/$/", "/friends\/*/", "/^\/groups\/*/", "/^\/forums\/*/", "/\/groups\/create\//", "/\/site-tracking\/create\//", "/\/members\/[^\/]*\/groups\//", "/\/members\/[^\/]*\/forums\//", "/\/members\/[^\/]*\/settings\//");
    
    if (!is_pro_user($userid) ) {
    
    		foreach($not_allowed as $check)
    		{
    		if(preg_match($check, $uri))
    		{
    			wp_redirect(home_url("/upgrade/"));
    			exit;
    		}
    	}
    
    }else{
    
    }
    }
    
    add_action("init", "prosites_hide_buddypress_uri");