Page 1 of 1

Help! How to show membership registration & expiry date?

PostPosted: September 3rd, 2011, 7:38 am
by candy
Hi,

I have searched around but could not find anything that fits :-(

I want to make a page where the user will see the details about his membership.

Registration date, next due renewal date, cancelation button (to be deactivated 14 days before next due renewal date - like if he did not cancel at least 14 days in advance, renewal will go on)

I only found this: <?php echo S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME; ?>

but this gives the unix stamp and I want to show the normal readable date not the unix stamp! And have no clue how to do it :-(

Thanks!

Re: Help! How to show membership registration & expiry date?

PostPosted: September 3rd, 2011, 1:20 pm
by Cristián Lávaque
You can work with the timestamp using PHP's time/date functions, like date(). http://php.net/date

For the EOT, this may help:

Code: Select all
$eot_time get_user_field('s2member_auto_eot_time'$user_id); 


If you need something more advanced, you could use the Notifications API to create your own logs and use those to display your messages.

We're working on improving this in future releases.

Re: Help! How to show membership registration & expiry date?

PostPosted: September 4th, 2011, 8:18 am
by candy
Hi,

No way to get that, sorry :-(
Browsed through all that php jungle, all they talk about is how to convert a date in unix stamp, whereas I need exactely the opposite! And as I am not a programmer, most of that stuff is chinese for me anyways ...

Really, is there NO way to show people when their membership expires?
I think this is bad and many might feel cheated or so, give them the feeling we are hiding something, and that's definitely NOT what I want ...

I tried with <?php $eot_time = get_user_field('s2member_auto_eot_time', $user_id); ?> too ... but it does not show anything !??!
blank!??!

Help! This might be also legally a problem, if people have no way to clearly see when their membership expires or when next payment is due ...

Thanks!

Re: Help! How to show membership registration & expiry date?

PostPosted: September 4th, 2011, 11:26 am
by camillemm
Code: Select all
<?php if (function_exists('$s2member_auto_eot_time')){$s2member_auto_eot_time = $s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time");} ?>
<?php
echo date("j F Y", $s2member_auto_eot_time);
?>


You should search in this forum as it has been explained how to do that (before complaining).

Re: Help! How to show membership registration & expiry date?

PostPosted: September 5th, 2011, 12:09 am
by Cristián Lávaque
Candy, this thread may have info you can use for this: viewtopic.php?f=4&t=6196

Here's a code example:

Code: Select all
if ($days get_user_option('s2member_auto_eot_time'))
{
    
$days ceil(($days time()) / 86400);

    if (
$days 1)
        echo 
'Your subscription has expired.';
    elseif (
$days == 1)
        echo 
'Your subscription will end tomorrow!';
    else
        echo 
'You have '$days' days left.';


Note that those with a subscription don't have an EOT time until they stop the subscription in some way (e.g. cancelled).

I hope that helps. :)

Re: Help! How to show membership registration & expiry date?

PostPosted: September 5th, 2011, 12:13 am
by Cristián Lávaque
camillemm wrote:
Code: Select all
<?php if (function_exists('$s2member_auto_eot_time')){$s2member_auto_eot_time = $s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time");} ?>
<?php
echo date("j F Y", $s2member_auto_eot_time);
?>


Thanks a lot for the date() example! http://php.net/date

One correction: $s2member_auto_eot_time is a variable, not a function, and the value of that variable won't be a function either, so that will always be false. In the example above I used an if that I believe is close to what you wanted to show.

Re: Help! How to show membership registration & expiry date?

PostPosted: November 21st, 2011, 1:18 pm
by zauber
Thanks, Cristián. There is something funky in that code, I think, but since only members in good standing will see the EOT for me, I could take out the conditional and it works fine. I threw it into my functions.php file as a new shortcode--seems like it would definitely be a nice thing to include as a default shortcode...

Re: Help! How to show membership registration & expiry date?

PostPosted: November 21st, 2011, 6:10 pm
by raygulick
Code: Select all
if (function_exists('$s2member_auto_eot_time')){$s2member_auto_eot_time = $s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time");} ?>
<?php
   echo '<p><em>Membership expires ';
   echo date("F j, Y", $s2member_auto_eot_time);
   echo '</em></p>';

This is a slight modification to the code shown above, but all it returns is the following, no matter what date the EOT is set at:
Membership expires January 1, 1970

Am I missing something obvious?

Re: Help! How to show membership registration & expiry date?

PostPosted: November 21st, 2011, 7:24 pm
by zauber
As I said, I don't really need it, but I think (untested!) this should work:

Code: Select all
if ($s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time") ) {
   echo '<p><em>Membership expires ';
   echo date("F j, Y", $s2member_auto_eot_time);
   echo '</em></p>';
}


That is, if the assignment succeeds, the assignment evaluates as true. Again, not really coder, so take it with a huge chunk of salt.

Re: Help! How to show membership registration & expiry date?

PostPosted: November 21st, 2011, 7:29 pm
by raygulick
OK. That shows the actual EOT date; much better, thanks!

Re: Help! How to show membership registration & expiry date?

PostPosted: November 21st, 2011, 8:19 pm
by raygulick
This displays expiration date for members who have been manually added, with the EOT manually specified, but how would I show expiration date for members who have registered in the system, and therefore have no value for s2member_auto_eot_time? Is there another field I should be looking for?

Re: Help! How to show membership registration & expiry date?

PostPosted: November 25th, 2011, 11:24 pm
by Cristián Lávaque
The thing is that users that have a subscription don't get an EOT time until the subscription stops for some reason. This will improve in the future.

You could probably work with the payment time and based on that, determine when he should be paying next. Like, if he started paying on a day 23rd of the month, then you can assume he pays every 23rd if it's a montly subscription. You can find the payment times mentioned under WP Admin -> s2Member -> API / Scripting -> s2Member Content Dripping.

I hope that helps. :)