PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Non-Recurring payments: last Payment and renewal?

s2Member Plugin. A Membership plugin for WordPress®.

Non-Recurring payments: last Payment and renewal?

Postby FrancescoRizzi » April 24th, 2011, 5:41 pm

Hi all.
The site I'm working on is using non-recurring PayPal payments (aka BuyNow) to give yearly membership.

I have a couple of questions inr egard:

1~ I've found and read about the s2member_last_payment_time global, which should provide access to the date of the current user latest payment. However, as Jason pointed out here:
This will ONLY be available for paying Members, and ONLY if you've used a "Subscription" Button. It won't work for Buy Now transactions.

Is there an equivalent for non-recurring payments? We're trying to display on screen when they paid for the membership (or renewed it).
[I think one option is for us to include a custom field when they pay and then rely on that, but I'd really love to be able to do this without writing more custom code, if possible.]

2~ Speaking of renewals... what'd the recommended approach for letting users renew with BuyNow payments? Off the top of my head, I guess I would include a form in the Members-Only area of the site (aka some page requiring them to be logged in and active members at level 1+); by checking their current membership I can figure out what membership level they currently have and build a form equivalent to what they used to signup the first time, or at least the PayPal CheckOut button that was on it.
Is that the common approach or are there better options?

Thanks in advance,
FR
User avatar
FrancescoRizzi
Registered User
Registered User
 
Posts: 21
Joined: December 2, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » April 24th, 2011, 8:51 pm

Hi Francesco. :)

Every Member will ALWAYS have a registration time associated with their account, so you could probably use this s2Member API Constant to accomplish what you need: S2MEMBER_CURRENT_USER_REGISTRATION_TIME. WP Admin -> s2Member -> API Scripting -> API Constants

Code: Select all
<?php echo S2MEMBER_CURRENT_USER_REGISTRATION_TIME; ?>

or the s2member shortcode equivalent:
Code: Select all
[s2Get constant="S2MEMBER_CURRENT_USER_REGISTRATION_TIME" /]


This may output something like: 1270537981. This is a Unix timestamp, which is based on seconds, and you can format it with the date function. http://php.net/date

Regarding renewals, when adding more time to their membership before their EOT is up, will cause the previous one to end and the new one to start at the time of payment.

This is something we're planning to improve, but in the meantime you can fix it with this trick:

Create this directory and file /wp-content/mu-plugins/s2-hacks.php. Inside the file, add this code. Be sure there are NO spaces or line breaks before or after <?php ?>

* This code is untested, but it should work fine. Please let me know if you have any trouble.

Code: Select all
<?php
add_action
('ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars', 'during_before_subscr_signup_w_update_vars');
function during_before_subscr_signup_w_update_vars($vars = array())
{
    $GLOBALS['existing_s2_eot_time'] = get_user_option('s2member_auto_eot_time', $vars['user_id']);
}

add_action('ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars', 'during_subscr_signup_w_update_vars');
function during_subscr_signup_w_update_vars($vars = array())
{
    if (($eot_time = get_user_option('s2member_auto_eot_time', $vars['user_id'])) && $GLOBALS['existing_s2_eot_time'])
        update_user_option($user_id, 's2member_auto_eot_time', $eot_time + ($GLOBALS['existing_s2_eot_time'] - time ()));
}
?>


Let me know if that helps.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby FrancescoRizzi » April 24th, 2011, 8:57 pm

Cristián, thanks for the tips. I'm putting the keyboard down for the night but will test them out asap and let you know. S2MEMBER_CURRENT_USER_REGISTRATION_TIME, in particular, may be the right one for us.
And thanks for the heads-up on the auto-killing of the current membership upon renewal: I'm sure that would have been a headscratcher :)
User avatar
FrancescoRizzi
Registered User
Registered User
 
Posts: 21
Joined: December 2, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » April 24th, 2011, 9:11 pm

;)

I look forward to your update.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby FrancescoRizzi » April 25th, 2011, 3:38 pm

Haven't tried yet on the renewal - but the code you shared makes sense to me so I think it may just hit the spot.

Regarding the registration time, I think S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME may fit our bill even better than S2MEMBER_CURRENT_USER_REGISTRATION_TIME (but thanks for pointing that out to me), since we're trying to display the time when the user paid for the membership..
However, I'm not sure if either is quite right for us...

Based on the API/Scripting documentation,
for S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME
[...] However, this will be 0 if they're not logged in; or if they've never paid you at all ( i.e. if they're still a Free Subscriber ). This holds the recorded time at which the Member originally registered their Username (or upgraded for) any type of "paid" access to your site. This value is preserved for the lifetime of their account, even if they upgrade, and even if they're demoted at some point. Once this value is recorded, it never changes under any circumstance.

So if I have a user that registers... then pays for membership on Jan 1st... then renews or upgrades on Feb 1st... if I'm reading the docs correctly S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME would report Jan 1st (whereas we'd love to say "Your membership was renewed on Feb 1st")

And S2MEMBER_CURRENT_USER_REGISTRATION_TIME is not quite it either, since it
holds the recorded time at which the User originally registered their Username for access to your site; for free or otherwise.


Hmm... is
Code: Select all
get_user_option ("s2member_auto_eot_time", $uid);
going to give me the time when the user's membership expires? 'cause.. well, our memberships are annual, I might just take 365 days away from that value...
User avatar
FrancescoRizzi
Registered User
Registered User
 
Posts: 21
Joined: December 2, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » April 25th, 2011, 8:02 pm

Yeah, I see what you mean with the constants. Those are the ones available right now.

FrancescoRizzi wrote:Hmm... is
Code: Select all
get_user_option ("s2member_auto_eot_time", $uid);
going to give me the time when the user's membership expires? 'cause.. well, our memberships are annual, I might just take 365 days away from that value...


Yeah, that could work to figure out the last time a payment was made. Good thinking. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » April 26th, 2011, 1:21 am

I'm looking at s2Member Pro's Import tool's documentation and one of the fields is "Last Payment Date ( mm/dd/yyyy )", so it looks like the date you want may be there in the database already.

Why don't you try this?

Code: Select all
get_user_option('s2member_last_payment_date', S2MEMBER_CURRENT_USER_ID); 


I don't have paid members in my installation of s2Member, so I can't confirm that it works, but I thought I'd let you know.

I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby FrancescoRizzi » April 26th, 2011, 5:48 am

It does, it does! Thanks Cristián for looking into this: you're awesome, man!
User avatar
FrancescoRizzi
Registered User
Registered User
 
Posts: 21
Joined: December 2, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » April 26th, 2011, 10:34 am

Great! :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » April 26th, 2011, 1:12 pm

Actually, I think you don't even need to use the ID of the user...

Code: Select all
<?php echo get_user_option("s2member_last_payment_time"); ?>


That may return a Unix timestamp in seconds, which you'd format with date. http://php.net/date
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Jason Caldwell » April 27th, 2011, 12:33 am

Cristián Lávaque wrote:Actually, I think you don't even need to use the ID of the user...

Code: Select all
<?php echo get_user_option("s2member_last_payment_time"); ?>


That may return a Unix timestamp in seconds, which you'd format with date. http://php.net/date

Yes, this is the one you'd want to use in this circumstance.
Yes, this returns a Unix Timestamp.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Non-Recurring payments: last Payment and renewal?

Postby FrancescoRizzi » May 7th, 2011, 11:03 am

Hey Cristián (/wave Jason).
Regarding the sniplet you gave me here:
Cristián Lávaque wrote:Regarding renewals, when adding more time to their membership before their EOT is up, will cause the previous one to end and the new one to start at the time of payment.

This is something we're planning to improve, but in the meantime you can fix it with this trick:

Create this directory and file /wp-content/mu-plugins/s2-hacks.php. Inside the file, add this code. Be sure there are NO spaces or line breaks before or after <?php ?>

* This code is untested, but it should work fine. Please let me know if you have any trouble.

Code: Select all
<?php
add_action
('ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars', 'during_before_subscr_signup_w_update_vars');
function during_before_subscr_signup_w_update_vars($vars = array())
{
    $GLOBALS['existing_s2_eot_time'] = get_user_option('s2member_auto_eot_time', $vars['user_id']);
}

add_action('ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars', 'during_subscr_signup_w_update_vars');
function during_subscr_signup_w_update_vars($vars = array())
{
    if (($eot_time = get_user_option('s2member_auto_eot_time', $vars['user_id'])) && $GLOBALS['existing_s2_eot_time'])
        update_user_option($user_id, 's2member_auto_eot_time', $eot_time + ($GLOBALS['existing_s2_eot_time'] - time ()));
}
?>




Could this go in my theme's functions.php file instead?
Our WP installation is not running MU/MultiSite enabled so I'm not sure if I want/need to mess with /wp-content/mu-plugins/s2-hacks.php...

Thanks,
F
User avatar
FrancescoRizzi
Registered User
Registered User
 
Posts: 21
Joined: December 2, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Jason Caldwell » May 7th, 2011, 12:32 pm

FrancescoRizzi wrote:Could this go in my theme's functions.php file instead?
Our WP installation is not running MU/MultiSite enabled so I'm not sure if I want/need to mess with /wp-content/mu-plugins/s2-hacks.php...

The /wp-content/mu-plugins/ directory.
(mu) stands for MUST USE plugins, and these are not *just* for Multisite Networking, they can be used on any WordPress® installation. If you don't have this directory, /wp-content/mu-plugins/ please create it.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Non-Recurring payments: last Payment and renewal?

Postby FrancescoRizzi » May 7th, 2011, 1:08 pm

Jason Caldwell wrote:The /wp-content/mu-plugins/ directory.
(mu) stands for MUST USE plugins, and these are not *just* for Multisite Networking,


ach! my hash for 2-letter acronyms collided, sorry.
Thanks for the clarification: mu shall work then ;)
User avatar
FrancescoRizzi
Registered User
Registered User
 
Posts: 21
Joined: December 2, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby Jason Caldwell » May 10th, 2011, 4:19 pm

Cool. Thanks for reporting back on this.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Non-Recurring payments: last Payment and renewal?

Postby adamarling » May 24th, 2011, 2:25 am

Hi,

Can anyone else verify this hack works for them?
>> /wp-content/mu-plugins/s2-hacks.php

I can only offer non-recurring memberships, which last for 1 year, in my system. I just tried a test renewal, and it updated the EOT date to 1 year from today's date. However when I renew the same account a second time, I assume it would push the EOT date on the membership to 2 years into the future, but it stays '2012', just one year ahead.

Do you know if this hack accounts for multiple years in advance 'renewing' a non-recurring membership?

I'm looking for a situation as such:
Original Membership 10/28/2010.
Renewed on 5/20/2011 (say they would like to renew 6 months in advance)
New EOT for Membership would be 10/28/2012.

(ps. the reason I can't offer recurring memberships is that members will often be paying with company or university credit cards and generally are not allowed to pay by recurring payment).

thanks.
User avatar
adamarling
Registered User
Registered User
 
Posts: 27
Joined: May 12, 2011

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » May 24th, 2011, 11:08 am

This hack is to achieve what you're asking for. You can try it yourself and see if it works. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby adamarling » May 24th, 2011, 1:25 pm

Hey Cristian, thanks for the reply. Sorry to be unclear in my previous post, however I did create the directory, the file, and all was in place prior to me making this post. When I ran the 'renewal' subscription, the year does not update. So for me, I guess it didn't work...
User avatar
adamarling
Registered User
Registered User
 
Posts: 27
Joined: May 12, 2011

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » May 24th, 2011, 1:36 pm

OK. I think the coming release of s2Member will have this included, so you won't need the hack anymore. Any day now. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Non-Recurring payments: last Payment and renewal?

Postby adamarling » May 24th, 2011, 4:57 pm

Awesome. Looking forward to it. s2Member Pro is the best money I've spent in quite some time. You guys rule.
User avatar
adamarling
Registered User
Registered User
 
Posts: 27
Joined: May 12, 2011

Re: Non-Recurring payments: last Payment and renewal?

Postby Jason Caldwell » May 24th, 2011, 7:54 pm

Thanks for the kudos. Yes, this is coming in the next release. It's a configurable option under: s2Member -> PayPal Options -> EOT Behavior. If you're an s2Member Pro customer with an Unlimited Site License, it's already available inside your account at s2Member.com. We're currently running tests against the release candidate with Unlimited Site Licenses.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Non-Recurring payments: last Payment and renewal?

Postby adamarling » May 27th, 2011, 4:41 pm

Hi Jason,

2 quick questions:

1.) Do you know an estimated release date of s2Member Pro which will include this feature?
2.) Working with existing functions available and some coding on my end, is it possible to create a custom mod to make this work on my end?

thanks,
Adam
User avatar
adamarling
Registered User
Registered User
 
Posts: 27
Joined: May 12, 2011

Re: Non-Recurring payments: last Payment and renewal?

Postby Jason Caldwell » May 27th, 2011, 5:03 pm

Should be within a week Adam. So far all tests have returned positive results. Unless we have something major come up, I don't see any reason we can't release it publicly next week.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Non-Recurring payments: last Payment and renewal?

Postby adamarling » June 6th, 2011, 1:22 pm

Hi Jason,

Not to be a bother, but any ETA on the EOT Renewal feature noted above? I'm starting to get duplicate records added to my s2Member system when expired members renew, so if it will be a while I'll attempt a workaround.

thanks,
Adam
User avatar
adamarling
Registered User
Registered User
 
Posts: 27
Joined: May 12, 2011

Re: Non-Recurring payments: last Payment and renewal?

Postby Cristián Lávaque » June 6th, 2011, 4:18 pm

The setting is in there in the latest release. WP Admin -> s2Member -> PayPal Options -> Automatic EOT Behavior -> Fixed-Term Extensions (auto-extend) :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Next

Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 2 guests

cron