Community Support Forums — WordPress® ( Users Helping Users ) — 2011-12-04T03:30:26-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=6196 2011-12-04T03:30:26-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=54515#p54515 <![CDATA[Re: Display account variables in theme]]>

Code:
<?php
       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.';
    }
?>



I just pasted this code in my my account page HTML..

but not working for me..i already installed php execution plugin..

What i need to do work..There is no output coming for me..

Statistics: Posted by vigneshrajesh — December 4th, 2011, 3:30 am


]]>
2011-05-03T23:54:50-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=14062#p14062 <![CDATA[Re: Display account variables in theme]]>

Statistics: Posted by Cristián Lávaque — May 3rd, 2011, 11:54 pm


]]>
2011-05-03T23:35:53-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=14055#p14055 <![CDATA[Re: Display account variables in theme]]>
http://screencast.com/t/zJyabJ3hX
Image




theone wrote:
That's the ticket! Thanks so much for the assistance, greatly appreciated!

For anyone who stumbles upon this thread and wants to cut to the chase.......

Code:
<?php
       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.';
    }
?>

Statistics: Posted by adriarichards — May 3rd, 2011, 11:35 pm


]]>
2011-04-29T21:32:24-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13849#p13849 <![CDATA[Re: Display account variables in theme]]> 's2member_last_payment_time' instead of 's2member_auto_eot_time', and you'd change the math to figure out the days left.

Statistics: Posted by Cristián Lávaque — April 29th, 2011, 9:32 pm


]]>
2011-04-29T20:54:04-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13844#p13844 <![CDATA[Re: Display account variables in theme]]>
Cristián Lávaque wrote:
Yeah, it makes sense, but then you also need to figure out which of the two you're dealing with so you know if you are talking about 1 or 3 months.


Ok, first off, how do we call on a users last payment? And then what? do we check it against a null value?

Statistics: Posted by theone — April 29th, 2011, 8:54 pm


]]>
2011-04-28T00:43:26-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13649#p13649 <![CDATA[Re: Display account variables in theme]]>

Statistics: Posted by Cristián Lávaque — April 28th, 2011, 12:43 am


]]>
2011-04-27T23:38:35-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13646#p13646 <![CDATA[Re: Display account variables in theme]]>
This will really help clarify my members options page.

Statistics: Posted by theone — April 27th, 2011, 11:38 pm


]]>
2011-04-27T22:42:00-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13641#p13641 <![CDATA[Re: Display account variables in theme]]> else part at the end):

Code:
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.';
} else {
    echo 
'Your subscription has expired.';

Statistics: Posted by Cristián Lávaque — April 27th, 2011, 10:42 pm


]]>
2011-04-27T20:37:18-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13636#p13636 <![CDATA[Re: Display account variables in theme]]> Statistics: Posted by theone — April 27th, 2011, 8:37 pm


]]>
2011-04-27T20:29:40-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13635#p13635 <![CDATA[Re: Display account variables in theme]]>
For anyone who stumbles upon this thread and wants to cut to the chase.......

Code:
<?php
       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.';
    }
?>

Statistics: Posted by theone — April 27th, 2011, 8:29 pm


]]>
2011-04-27T20:01:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13634#p13634 <![CDATA[Re: Display account variables in theme]]> floor, round it up with ceil.

Statistics: Posted by Cristián Lávaque — April 27th, 2011, 8:01 pm


]]>
2011-04-27T19:02:11-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13632#p13632 <![CDATA[Re: Display account variables in theme]]>
Here's the problem I see what that script.

Code:
if ($days < 1) echo 'Your subscription has expired.';

elseif ($days == 1) echo 'You have a few hours left, renew now!';


This actually doesn't work since we are counting in days. Anything from 00:00:00-23:59:59 hours is equal to 0. Anything from 24:00:00-47:59:59 is equal to '1'.

This creates a problem because if there are 17 hours left that person is going to see "Your subscription has expired.".

If the person has 47 hours left they will see "You have a few hours left, renew now!."

Do you understand the problem? I hope I was able to explain that clearly. Any ideas on a fix for this?

Statistics: Posted by theone — April 27th, 2011, 7:02 pm


]]>
2011-04-27T18:26:54-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13630#p13630 <![CDATA[Re: Display account variables in theme]]>
Code:
$days floor((get_user_option('s2member_auto_eot_time') - time()) / 86400);

if (
$days 1)
    echo 
'Your subscriptions has expired.';
else if (
$days == 1)
    echo 
'You have a few hours left, renew now!';
else
    echo 
'You have '$days' days left.'

Statistics: Posted by Cristián Lávaque — April 27th, 2011, 6:26 pm


]]>
2011-04-27T18:14:05-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13628#p13628 <![CDATA[Re: Display account variables in theme]]>
This is with EOT set mind you.

Statistics: Posted by theone — April 27th, 2011, 6:14 pm


]]>
2011-04-27T17:03:13-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13617#p13617 <![CDATA[Re: Display account variables in theme]]>

If there's just one day left, you can assume he has only ours before it's up. Here's how I'd write it:

Code:
if ($days = get_user_option('s2member_auto_eot_time'))
{
    $days = floor(($days - time()) / 86400);

    if ($days < 1)
        echo 'Your subscription has expired.';
    elseif ($days == 1)
        echo 'You have a few hours left, renew now!';
    else
        echo 
'You have ', $days, ' days left.';
}
 


Does it help?

Statistics: Posted by Cristián Lávaque — April 27th, 2011, 5:03 pm


]]>
2011-04-27T15:39:56-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13599#p13599 <![CDATA[Re: Display account variables in theme]]>

This will allow me to display a 'Subscription has expired!' message if the amount is anything less than 0.

Code:
<?php
$remaining_days = floor((get_user_option('s2member_auto_eot_time') - time()) / 86400);
if ($remaining_days<="0")
  echo "Subscription has expired!";
else
  echo "$remaining_days";
  print ' day' . ($remaining_days == 1 ? '' : 's');
  print ' left';
?>


BUT, what if I want to be able to tell the difference between an account that has a few hours left and one that has expired. How would I do that?

Statistics: Posted by theone — April 27th, 2011, 3:39 pm


]]>
2011-04-27T10:45:21-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13559#p13559 <![CDATA[Re: Display account variables in theme]]>
Thanks so much!

JUST ONE THING - How do I prevent a negative integer from showing if someone is beyond their EOT? I just want it to say 0. Any ideas on that?

ALSO, I have s2member set to demote a member to 'level 0'. We determined that an EOT must be set and that the user must be at least "level 1" for the data to return properly. So, how would I fix it so that if the user = 'level 0' to always display '0' and not a negative number? Because right now, if a user is a "subscriber" and no EOT is set I get something like '-15092'. I want to replace that with '0'. (I hope that was clear enough).

Im thinking that some sort of 'if / else' statement would do it. But, again me and PHP don't get along very well. I'd appreciate it if you could hold me hand through this one :)

Statistics: Posted by theone — April 27th, 2011, 10:45 am


]]>
2011-04-27T01:13:56-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13515#p13515 <![CDATA[Re: Display account variables in theme]]>
Could you tell me what this outputs?

Code:
<?php echo get_user_option('s2member_auto_eot_time'); ?>

Statistics: Posted by Cristián Lávaque — April 27th, 2011, 1:13 am


]]>
2011-04-27T00:59:27-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13513#p13513 <![CDATA[Re: Display account variables in theme]]> Statistics: Posted by theone — April 27th, 2011, 12:59 am


]]>
2011-04-26T22:04:47-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13485#p13485 <![CDATA[Re: Display account variables in theme]]>

Could you try this?

Code:
$remaining_days = floor((get_user_option('s2member_auto_eot_time') - time()) / 86400);  


I added floor to round the fractions down. http://php.net/floor

Statistics: Posted by Cristián Lávaque — April 26th, 2011, 10:04 pm


]]>
2011-04-26T16:56:46-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13468#p13468 <![CDATA[Re: Display account variables in theme]]>
'15090.9007292'

Code:
<?php
$remaining_days = (time() - get_user_option('s2member_auto_eot_time')) / 86400;

echo "<p>$remaining_days</p>";

?>


My brain isn't good at comprehending these types of equations. I've tried many time to learn PHP but some people (myself) are just not made to write code.

I guess I'll just have to imagine how convenient it would have been to be able to allow my customers to know how many days remain in their subscription.

Statistics: Posted by theone — April 26th, 2011, 4:56 pm


]]>
2011-04-26T13:23:22-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13453#p13453 <![CDATA[Re: Display account variables in theme]]>
You can find out the remaining time substracting that time from the current time and turn the seconds into days. Something like

Code:
$remaining_days = (time() - get_user_option('s2member_auto_eot_time')) / 86400


http://php.net/time
http://www.google.com/search?q=1+day+to+seconds

I hope that helps. :)

Statistics: Posted by Cristián Lávaque — April 26th, 2011, 1:23 pm


]]>
2011-04-26T12:59:22-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13447#p13447 <![CDATA[Re: Display account variables in theme]]>
Now I get a return but it shows something like '1303840859'.

What do these numbers mean?

Also, am I correct to assume that there's no defined variable to output the time remaining and that some additional programing would be required to translate the EOT time into the number of remaining days?

Statistics: Posted by theone — April 26th, 2011, 12:59 pm


]]>
2011-04-26T11:25:00-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13421#p13421 <![CDATA[Re: Display account variables in theme]]> WP Admin -> Users -> [user] -> Automatic EOT Time

Statistics: Posted by Cristián Lávaque — April 26th, 2011, 11:25 am


]]>
2011-04-26T10:46:55-05:00 http://www.primothemes.com/forums/viewtopic.php?t=6196&p=13416#p13416 <![CDATA[Re: Display account variables in theme]]> Statistics: Posted by theone — April 26th, 2011, 10:46 am


]]>