View Full Version : Has posted today conditional?
Razasharp
12-23-2012, 03:09 AM
Is there a conditional I can use for the member profiles to check whether the user has posted today? I'd like to show a graphic if they have.
I noticed the welcome headers hack has this conditional:
<if condition="$headerstime - 1209600 > $bbuserinfo[lastpost]">
So perhaps I could use something like that? Maybe something like if Date.today == $bbuserinfo[lastpost].day
Anyone have any ideas?
Thanks in advance.
If you mean "within the past 24 hours" then (assuming the $bbuserinfo[lastpost] is set) you can check it by subtracting $bbuserinfo[lastpost] from TIMENOW and comparing the result to 86400 (seconds in 24 hours).
If you mean "on today's date" then you'd need a plugin with more code to figure that out. Basically get the day-month-year for today and the post time, and see if they're the same, or maybe get the timestamp for midnight at the start of today and see if $bbuserinfo[lastpost] is greater (and you might have to deal with timezones depending on what you mean by "today").
Razasharp
12-23-2012, 02:39 PM
If you mean "within the past 24 hours" then (assuming the $bbuserinfo[lastpost] is set) you can check it by subtracting $bbuserinfo[lastpost] from TIMENOW and comparing the result to 86400 (seconds in 24 hours).
If you mean "on today's date" then you'd need a plugin with more code to figure that out. Basically get the day-month-year for today and the post time, and see if they're the same, or maybe get the timestamp for midnight at the start of today and see if $bbuserinfo[lastpost] is greater (and you might have to deal with timezones depending on what you mean by "today").
Hi Kevin - thanks for the reply. I'm trying this but it doesn't work :/
<if condition="$timenow = TIMENOW">
<if condition="$bbuserinfo[lastpost] > $timenow - 86400">
(Has posted within the last 24 hours)
</if>
</if>
If the lastpost time is greater than now-minus-24hours - it should return true?
I am half asleep though so probably doing something wrong :o
I think you'd want something like this:
<if condition="TIMENOW - $bbuserinfo[lastpost] < 86400">
// posted in last 24 hours
</if>
Razasharp
12-23-2012, 02:58 PM
Hi Kevin
That doesn't work either :/
(It returns true for everyone)
Oh - you probably want to use $userinfo, because $bbuserinfo will always be you, no matter whose profile you're viewing.
Razasharp
12-23-2012, 03:05 PM
Oh - you probably want to use $userinfo, because $bbuserinfo will always be you, no matter whose profile you're viewing.
You're right! Duh, I should have thought of that! :o
Thank you :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.