Page 1 of 1

Set default EOT for all new members

PostPosted: August 8th, 2011, 11:03 pm
by man-O-media
Hi again,

How would I go about setting a default EOT for all new members/subscribers including free subscribers?

This is for a sports team site where there will often not be a relation between a payment and a EOT. There is a fee paid by a parent or guardian for a player, both of whom must register but there are multiple other people, coaches, managers, etc. who have an elevated level who pay nothing and more often than not, the payments which are made will be by check and not PayPal.
And at the end of the season, because the next seasons players must tryout and the coaches will often change, etc., everyone who registers should get an EOT of Jan 1 of the next year. So if someone registers today, their EOT would be 1/1/2012. If someone registers Jan 1, 2012, their EOT should be 1/12013.
Unless of course an admin goes in and manually sets a different EOT or they have indeed paid something and gotten a different EOT.

Right now I am manually going in to set each new subscribers EOT but I have already forgotten to set the date once or twice.

Obviously setting a EOT for a new free subscriber does not really achieve anything as I am not auto deleting accounts when the EOT date hits but if all new accounts get the EOT date then all I need to worry about is changing their level.

That all said, I'm not sure how to best handle setting a new EOT for those preexisting accounts who continue to the next year such as a player who makes the team again but I will cross that bridge when I get there.

DP

Re: Set default EOT for all new members

PostPosted: August 9th, 2011, 3:47 pm
by Cristián Lávaque
If you have s2Member Pro, you could use the import tool to change all the EOTs in bulk. WP Admin -> s2Member -> Import/Export -> Import

About setting the EOT on registration, you could try this:

Create dir/file /wp-content/mu-plugins/s2hacks.php
Code: Select all
<?php
add_action 
('ws_plugin__s2member_during_configure_user_registration', 's2_set_default_eot_time');
function s2_set_default_eot_time($vars = array()) {
    if (!is_admin() && $vars['processed'] === 'yes') {
        update_user_option($vars['user_id'], 's2member_auto_eot_time', strtotime(date('Y') . '-12-31'));
    }
}
?>


Let me know if that works. I hope it helps.

Re: Set default EOT for all new members

PostPosted: August 9th, 2011, 9:14 pm
by man-O-media
Many thanks Cristián,

If I understand, the code takes the current year and adds Dec 31st... Works for me, I will try it out in a little while.

I presume this will not get in the way of S2s normal operation for setting a EOT for paid items.

As for the import, yes I do have pro, in fact import<>export is one of the reasons I purchased Pro but not for this site and I have not looked at it at all yet.
Anyway, are you suggesting exporting all the users and then re-importing and during the import setting the date? Or just importing a new date into all users?
I suppose that could work in years to come however it is not something for just any Joe so I'm not sure its practical...

DP

Re: Set default EOT for all new members

PostPosted: August 10th, 2011, 11:21 am
by Cristián Lávaque
Yeah, about the import, I meant exporting the users, updating the EOT date and importing.

The hack should not affect the normal use of s2Member, just set your default s2member_auto_eot_time value on registration, that's it. Please test it and let me know how it goes.

Re: Set default EOT for all new members

PostPosted: August 20th, 2011, 11:41 pm
by man-O-media
Cristián Lávaque wrote:The hack should not affect the normal use of s2Member, just set your default s2member_auto_eot_time value on registration, that's it. Please test it and let me know how it goes.

I have been stuck on another site the last days so have not had a chance to getback to this but as it ends up, this site has a very similar issue so I have used the same idea.

And yea, it seems to set the EOT date just fine...

Correct me if I am wrong but with the way s2 works, if I have EOT "Fixed-Term Extensions ( auto-extend )?" set to automatically extend existing EOT, because this function has already set the EOT to Dec 31, all future 1 year buy now renewals will always go from that date?


Many thanks, DP

Re: Set default EOT for all new members

PostPosted: August 22nd, 2011, 8:57 pm
by Cristián Lávaque
Yes. If you create a 1 year buy-now button, it'll extend their paid time until next year's Dec 31st.