Set all users to have the same EOT no matter when they sign up

I was hoping to be able to set something up like this:

They should be able to renew for next year starting October first, but not take effect until January first, or midnight December 31st. They should be allowed to register for the current year up to September 30th. A note should be included explaining that dues paid before October 1st will be for the current year, and dues paid on October 1st will be for the following year starting in January. So access will run January through December.

i found this link: https://s2member.com/kb-article/how-do-you-create-a-subscription-that-ends-on-a-fixed-date/

but this would require my clients to go in every year and change the EOT. Is there a better way?

I have this exact same question.

What exactly do you mean by

If they are renewing would the not already be ā€œin effectā€ until the end of thes year? If so, would it not be sufficient to just extend their membership by adding another year i.e. extending the EOT by one year?

You might start with some code like this in a ā€œmust useā€ (MU) plugin like s2hacks.php:

    add_action ("ws_plugin__s2member_during_configure_user_registration_front_side", "my_fixed_EOT_time");
    function my_fixed_EOT_time ($vars)
        {
            $expire_on = strtotime(date('Y') . '-12-31');
            update_user_option ($vars["user_id"], "s2member_auto_eot_time", $expire_on);
        }

Other hooks that may be of use:

  • ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars
  • ws_plugin__s2member_during_paypal_notify_during_subscr_modify

Thanks for the reply Sonja. Iā€™m hoping that there is some way that when a client signs up, no matter when they signup, their membership will end on December 1st. Is that what this code does? The real trick here is that some people will want to signup early. So with your code it looks like if they come sign up on nov 15th of 2016, their membership will expire in 1.5 months (december 31, 2016), while if some one signs up on January 1st 2017, their membership will expire on Dec 31, of 2017. Is there a away to say if its November or december they will have through next year?

This code makes the membership end on Dec 31 of current year.

To handle early signups see http://php.net/date

date(ā€˜nā€™) will get the month number, then add 1 to the year if it is 11 or 12

IMHO having all memberships end on same date is such a common request from our customers that it should be an option. (Hope Jason or Raam are listening) .

2 Likes

I need this functionality as well - all of our plans ending on December 31st at midnight with the ability to renew for the upcoming year October-December the year prior. We wonā€™t be able to use s2Member without it.

Josh, were you able to work it out?

Hi Meagan.

What Sonja shared above is what Iā€™d suggest you try and customize for your use.

Iā€™m listening. :slight_smile:

Hi Megan, Itā€™s not ideal, but hereā€™s what I do:

Ad a file called s2-extend-eot.php to your mu-plugins folder. If you donā€™t have that folder just create it in your wp-content folder.

add this code:

<?php
add_action('init', function ()
{
    if(empty($_GET['s2_extend_eot'])
       || $_GET['s2_extend_eot'] !== 'gotime' )
        return; // Nothing to do here.

    $date_to_add = strtotime('12/31/2019');
    echo "date to add in time is :" . $date_to_add. "<br />";

    foreach(get_users() as $user)
    {
        if(($eot_time = get_user_option('s2member_auto_eot_time', $user->ID)))
            update_user_option($user->ID, 's2member_auto_eot_time', $date_to_add);
		echo get_user_option('s2member_auto_eot_time', $user->ID).'<br />';
    }
    exit('All EOT Times updated.');
});

Change the date to the date you want and click save before running this. Now go to this address: http://example.com/?s2_extend_eot=[secret key] (replacing example.com with your url and the [secret key] with ā€œgotimeā€. (no quotes.) You can change the secret key in line 5 above. Make sure you backup the first time you use this just in case.

1 Like