Membership subscription for content in a "gliding timeframe"

I want to use the membership plugin for subscriptions in the following way:
We publish a monthly report. The last three monthly reports are for subscribers only. All earlier reports are free.
So it seems to be easy to create a category "Monthly Reports", connect this category to a subscription and every month we add the newest report to this category and we change the category of the oldest report in "Monthly Reports" to a freely accessible category "Free Reports".
BUT: The subscribers pay per month. So if somebody subscribes in May (and pays for one month only) then he can access all three reports (May, April, March) in the category "Monthly Reports".
So: Is there an option like "access only content created since the day (or month) you have subscribed"? That would be the easiest solution to our problem ...
(I tried to find this information in the 60 page manual for membership - but because there is no index or table of contents in the manual it is hard to find specific information ...)

  • Arun Basil Lal
    • New Recruit

    Hello Emanaku,

    Interesting scenario here. But am afraid, there isn't any date based limitation that the Membership plugin can create.

    The only solution I can think of is creating a plan for every month. But that's a cumbersome.

    Let me think about this and see what I can suggest.

  • Timothy
    • Chief Pigeon

    Hey there.

    (I tried to find this information in the 60 page manual for membership - but because there is no index or table of contents in the manual it is hard to find specific information ...)

    You should be able to use the search feature for PDF files. cmd+f on Mac, I think its CTRL+f on Windows. I will add an index to the next update of the manual.

    What you want isn't entirely possible with our Membership plugin.... There was a plugin called Auto Delete Posts:

    Its old now so I don't know if it will work and I haven't tested it. But this plugin can move posts from one category to another after a period of time. So you could have one category for free and one for paid, the plugin moves them from the paid to free when you wish.

    The only other plugin I know (Or remember at least) is a little heavier but can schedule edits:

    So you should be able to schedule an edit to add an additional category. That way articles appear in both free and premium. You then just set up Membership accordingly.

    The other option is to duplicate, its not desirable though I would imagine. So you publish one article now in the premium category and then have another one in the free category and schedule it to publish some days, weeks or months later.

    There are some ideas there for you, hopefully this will get you sorted out. :slight_smile:

    Take care.

  • Emanaku
    • The Incredible Code Injector

    Thank you, Arun ...

    I studied the membership code and I saw that the connection between the access levels and the subscriptions is getting lost when adding the filters for the access levels.

    That makes it impossible just to add a simple "if date of post is older than date of of subscription then ...", because in the filter functions you do not know any more from which subscription the test about a certain level comes from.

    But for me things are rather simple:
    a. People have only one subscription and
    b. the access is restricted only at the one category "Monthly Reports".

    So my solution could be: I add a filter to "the_content" checking if
    1. the post's category is "Monthly Reports" and
    2. the post's date is older than the "startdate" of the (single) subscription the current_member has.

    If (and only if) 1. and 2. are true, then the user gets a message "you cannot see this because this report has been generated before your subscription started"
    In all other cases the access to this post is determined by the Membership level logic.

    This is a simple function ( 10-20 lines ) in my theme's functions.php - except getting the startdate for the member's subscription. For this I added a function get_startdates() in the classes/class.membership.php nearly identical to the function get_level_ids() - resulting in a list of startdates (one for each subscription).
    In my case this list will have only one element - so it is easy to use this one date in the filter for the_content ...

  • Emanaku
    • The Incredible Code Injector

    Thank you, Timothy,

    for the hints to these plugins that help you to shift posts from one category to another one or having several categories at once with schedules.

    As far as I can see both of these plugins do not provide an easy solution to mimic the time behaviour. So I have not followed this direction for this moment ...

  • Timothy
    • Chief Pigeon

    As far as I can see both of these plugins do not provide an easy solution to mimic the time behaviour. So I have not followed this direction for this moment ...

    From what I understand in those plugins you simple enter the date this takes affect as you post. So if you set it 30 days later, then it does just that.

    The membership plugin should handle the rest.

    I see from your other post you are now working on another solution, please let us know how you go.

    Take care.

  • Emanaku
    • The Incredible Code Injector

    ok, Timothy, I thought about your proposal a little bit more:
    It would be possible with the following four categories:

    Monthly Report (1 month)
    Monthly Report (2 months)
    Monthly Report (3 months)
    Free Reports

    Then in Membership I could set up three levels for each of the first three categories (level MR1, MR2 and MR3).

    The the definition of the subscription for the Monthly Reports then has after the "Starting Point" the subscription level MR1 "finite" for one month, then MR2 "finite" for one month and then MR3 "serial" monthly - all with the same price.

    When we publish a new report it gets all three categories.
    A month later we remove the "Monthly Report (1 month)" category from the report, and another month later we remove the "Monthly Report (2 months)" category and after three months we remove the "Monthly Report (3 months)" category, but give it the "Free Reports" category.

    That means: Each month when the new report comes out, we have to change the categories of three other reports to keep the "time frame" moving. This - I think - we could do by hand or the plugins you mentioned could be helpful to automate that ...

    The menu "Monthly Reports" would lead to a page showing a listing of the posts of all three categories. And what a user might see then is dependent, how many months her description is old ...

    I am sure this works regarding the access levels over time.

    I am not sure how this all looks like to the user - they should not be bothered by the 3 seperate categories or access levels - for them it's just "monthly reports" ...

    The advantage of course would be: no modification of the plugin ... :wink:

  • Emanaku
    • The Incredible Code Injector

    ok, Timothy, now we add "Weekly Mini-Reports".
    They also are free after three months.
    And who subscribe to them can only see the ones since he has subscribed.

    For this scenario I would need roughly 3x4=12 categories "Weekly (x weeks)" (x from 1 to 12) and whenever we add a new Mini-Report we would have to change the categories of 12 other Mini-Reports to realize the shifting time frame ...

    That seems to be a lot ... :wink:

  • Emanaku
    • The Incredible Code Injector

    I do not understand, Timothy, how I can prevent somebody to see the weekly reports published before his subscription started when I have just two access levels ...

    So for now I am going with the programming solution. In case somebody needs a similar thing, I include the two functions here. Please have in mind that I have a very simple access structure - the two levels are represented by posts in the categories "reports" (monthly) and "updates" (weekly). And: In my case people have only one subscription!!!

    in functions.php:

    //  To be used together with membership plugin
    //	Relies on an additional function "get_startdates" in membership/classes/class.membership.php
    //	allow members access to posts only, when they have subscribed BEFORE the creation of the post.
    function ema_check_membership_date ($content = null){
    	// check only when in category "reports" or "updates"
    	// these are resticted categories
    	// if the user is allowed to see content from these categories at all is handled by the membership plugin
    	if(in_category(array( 'reports', 'updates')) ) {
    		// date of post
    		$post_date = get_the_date('Y-m-d');
    		// date of subscription
    		if($member = current_member()){
    			$subs_dates = $member->get_startdates();
    			$subs_date = substr($subs_dates[0]->startdate, 0, 10); // assumption: user has only one subscription
    		} else {	// user not logged in
    			$subs_date = '9999-12-31';
    		if($post_date >= $subs_date) {
    			return $content;
    		} else {
    			$content = __("You cannot see this content",'ema-membership').' ('.__("created on ",'ema-membership').$post_date.") ";
    			$content.= __("because your subscription started later",'ema-membership')." (".__("on ",'ema-membership').$subs_date.") ";
    			$content.= __("and your subscription does not cover access to earlier generated content",'ema-membership');
    			return $content;
    	} else {	// not a protected category
    		return $content;

    The mentioned function of the membership class has to be included in membership/classes/class.membership.php

    // get the start date of the subscriptions of a logged in member
    		function get_startdates(){
    			$sql = $this->db->prepare( "SELECT startdate FROM {$this->membership_relationships} WHERE user_id = %d AND level_id > 0", $this->ID );
    			$startdates = $this->db->get_results( $sql );
    			return $startdates;

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.