Awhile back some one was looking how they could show a user's age beside their posts, I came up with this:
Open /themes/default/Display.template.php
Find // Show how many posts they have made.
Add Before // Calculate their age! Hopefully they are not too old ;)
if (!empty($message['member']['birth_date']))
{
if ($message['member']['birth_date'] != '0000-00-00')
{
list ($birth_year, $birth_month, $birth_day) = sscanf($message['member']['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
$message['member'] += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}
}
// Age
if (!empty($message['member']['age']))
echo '
Age: ', $message['member']['age'], '<br />';Thought it could be useful, but didn't think the edit was big enough to be a mod :P
// Calculate their age! Hopefully they are not too old ;)
if (!empty($message['member']['birth_date']))
{
if ($message['member']['birth_date'] != '0000-00-00')
{
list ($birth_year, $birth_month, $birth_day) = sscanf($message['member']['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
$message['member'] += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}
}
// Age
if (!empty($message['member']['age']))
echo '
Age: ', $message['member']['age'], '<br />';
Personally I'd format it like that :P ;).
-[Unknown]
formatted like yours :)
I entered the code where u said to and nothing changed ???
Make sure you change the Display template of the theme are using, it will only show the age if they have it set in thier profile ;)
I did that, I opened the Chatbubble theme I am using, than I editted the code like u said, and entered my own birthdate and looked at a post to see if it shows my age, and I didnt even get an Age: text anywhere
?
How can you do this to display the member's location and date they joined the forum?
use:
', $message['member']['registered'], '
', $message['member']['location'], '
Is there a way to display the date registered only (with no time)?
Zitat von: Senkusha in November 29, 2005, 10:50:59 VORMITTAG
Is there a way to display the date registered only (with no time)?
I'm also wondering if this is possible.
$txt[470] does not work for SMF 2.0 Beta 3
Needs fixed, please
Zitat von: jabop in April 10, 2008, 03:08:16 NACHMITTAGS
$txt[470] does not work for SMF 2.0 Beta 3
Replace that with $txt['not_applicable']
$txt['not_applicable'] worked correct?
Thanks for the tip.
Is there a way to make it where only the Admin or mods can see the ages?
Do you still need help with this NeedHelp?
thanks for the useful tip.