PDA

View Full Version : Conditional Based on lastactivity


Elenna
08-20-2007, 02:43 AM
I would like to display a box at the top of a user's profile if that user has either not logged in, or not updated their profile in the last 30 days (either one, but profile update preferred).

So I was thinking of making an IF conditional based on lastactivity... does anyone know how I would go about this?

ravyn
08-21-2007, 05:56 PM
there is a hack that shows when a user was last on in the postbit. I would imagine that the code used to add to the posbit would work in the profile.

https://vborg.vbsupport.ru/showthread.php?t=123366

but this hack recognizes visits as activity, not just posts, so if you want it to be registering when they posted last, the hack might need some customization.

Elenna
08-21-2007, 08:32 PM
Thanks very much, Ravyn! I'll give that a try.

Erm.... what would be the correct formating of the conditional? I'm not sure how to use dates. Is there a standard "30 days ago" or "1 week from now" kind of thing?

And would it be as easy as something like $userinfo[lastseen_date] < "-30 days"? Or must I call other functions to make it work?

EDIT:

I saw this working on a different site, so I wrote the webmaster and asked.

They are using a 3.0.x version, so I'd like to know what I need to do to get this to work with a 3.6.x version, or what I'm doing wrong so that this isn't working ;)

Since I want this to display in my profiles, I edit the member.php file.

I'm not sure where is safe to put the code, so I placed it above the "Main Script Start" section.

$time1weekago=time()-7776000;

if ($userinfo[lastactivity] < $time1weekago ) {
$isOlduser = 1;
} else {
$isOlduser = 0;
}

I then edit my MEMBERINFO template and place the IF conditional around the text, like this:

<if conditional="$isOlduser=1">User has not logged in for 1 week!</if>

Does anyone see anything 'wrong' with the above code, or why it might not be working for me?

I had it output its values for me, and here is what I get for myself (last activity is today):
Time 1 Week Ago: 1187212461
Last Activity: 1187817258
Is Old User: 1
This user has not logged in for 1 week!

I checked a member that had not logged in in over a month, and here is what I got:
Time 1 Week Ago: 1187212629
Last Activity: 1184946900
Is Old User: 1
This user has not logged in for 1 week!

Elenna
08-28-2007, 03:23 AM
Checking to see if anyone can take a look at this for me? See my last post, above.

Elenna
09-08-2007, 03:17 AM
Anyone? :D

Opserty
09-08-2007, 12:56 PM
$prevweek = time() - 7776000;

if ($userinfo[lastactivity] < $prevweek )
{
$olduser = 1;
}
else
{
$olduser = 0;
}



<if condition="$olduser == 1">
User has not logged in for 1 week!
</if>


You were only missing a second equals sign in the conditional and its condition not conditional but I made the rest of it look nice. It should work now.

You may want to add a new plugin instead of editing a file, a suitable hook location would be something like: memberinfo_complete.

Paul M
09-08-2007, 01:15 PM
No need for a plugin, just put the calculation in the template conditional ;

<if condition="$userinfo[lastactivity] < (TIMENOW - 2592000)">
User has not logged in for 30 days
</if>


(The value 7776000 is 90 days, not 30)

Elenna
09-10-2007, 03:00 PM
WONDERFUL, thanks every so much.