Showing the user's age beside thier post

Started by Jerry, December 20, 2004, 08:15:05 PM

Previous topic - Next topic

Jerry

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


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

[Unknown]

// 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]

Jerry



- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

homeslice

I entered the code where u said to and nothing changed  ???

http://battle.ne1.net

Wordabuse Hip-Hop Forums!


Jerry

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 ;)


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

homeslice

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

?

http://battle.ne1.net

Wordabuse Hip-Hop Forums!


jaijaymama

How can you do this to display the member's location and date they joined the forum?

A.M.A

use:

', $message['member']['registered'], '

', $message['member']['location'], '
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Senkusha

Is there a way to display the date registered only (with no time)?
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

BrotherBrian

Quote from: Senkusha on November 29, 2005, 10:50:59 AM
Is there a way to display the date registered only (with no time)?

I'm also wondering if this is possible.

jabop

$txt[470] does not work for SMF 2.0 Beta 3


Needs fixed, please

rsw686

Quote from: jabop on April 10, 2008, 03:08:16 PM
$txt[470] does not work for SMF 2.0 Beta 3

Replace that with $txt['not_applicable']
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Fiery

$txt['not_applicable']  worked correct?

Hoochie Coochie Man

İnadına SMF 1.1.X

NeedHelp

Is there a way to make it where only the Admin or mods can see the ages?

Oldiesmann

Do you still need help with this NeedHelp?
Michael Eshom
Christian Metal Fans

FlixyaFriend

samsung ue46c8000 [nofollow]

Advertisement: