[Membership 2 Pro] A suggestion for a configuration

We need to set up an annual subscription that subscribers can renew from year to year.
This subscription should start on January 1st and end on December 31st of each year for all subscribers.
If a subscriber subscribes for the first time after November, he should have free all the following year
Can you suggest me how to configure to get this result?

  • Dimitris
    • Support Star

    Hello there Akama_MU,

    hope you're doing well and thanks for reaching us! :slight_smile:

    I'm afraid you can't have automatic recurring payments for the yearly plan, as we should select the "one payment for a date-range access", so a user will have to manually re-buy this membership level after expiration.

    If a subscriber subscribes for the first time after November, he should have free all the following year

    There's no option in the plugin about this choice, if the above workaround about payments could work for you though, I could forward this "post-November" case to our Second Level Support team, in case they could provide some kind of hotfix (still can't promise that this will be possible in the first place).

    Warm regards,
    Dimitris

  • Akama_MU
    • New Recruit

    Within two weeks we got as customer 3 organization that asked the same feature:
    If a subscriber subscribes for the first time after November the first, he should pay the whole membership and have free all the following year.

    the one payment for a date-range access is ok for us, but please could you find a workaround for the "November first purchase"?

  • Panos
    • SLS

    Hi Akama_MU !

    So sorry it took us so long to get back to you!

    I have prepared a snippet that should be doing this, however this will not work with recurring payments. Here is the snippet :

    add_action( 'template_redirect', function(){
    
    	if ( ! isset( $_REQUEST['ms_relationship_id'] ) ) {
    		return;
    	}
    
    	$the_page = MS_Model_Pages::current_page();
    
    	if ( $the_page ) {
    
    		$the_type = MS_Model_Pages::get_page_type( $the_page );
    
    		if ( MS_Model_Pages::MS_PAGE_REG_COMPLETE == $the_type ) {
    
    			$months_to_apply_extension = array( 11, 12 );
    
    			if ( ! in_array( date('m') , $months_to_apply_extension ) ) {
    				return;
    			}
    
    			$subscription = MS_Factory::load(
    				'MS_Model_Relationship',
    				(int) $_REQUEST['ms_relationship_id']
    			);
    
    			$next_year = date('Y', strtotime('+1 year'));
    			$subscription->expire_date = date('Y-m-d', strtotime( "Dec 31 {$next_year}" ));
    			$subscription->save();
    
    		}
    
    	}
    
    }, 20 );

    This line here :
    $months_to_apply_extension = array( 11, 12 );
    contains the month number where this change should happen.

    You can add this snippet in a mu-plugin. If you are not familiar with mu-plugins, you can read more about them here :
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    In short, they are php files that live in your site's wp-content/mu-plugins folder. You can simply create that folder if it doesn't exist. Those files work like plugins, but they don't need to be activated. If you prefer you can add this at your child theme's functions.php file instead. However make sure you use a child theme in order not to lose your custom snippet after theme update.

    Hope this helps!

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.