Advertisement:

Author Topic: Showing the user's age beside thier post  (Read 29122 times)

Offline Jerry

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,903
  • Gender: Male
  • What? I can't hear you over my awesomeness!!
    • PlanetSMF
Showing the user's age beside thier post
« on: December 20, 2004, 08:15:05 PM »
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
Code: [Select]
// Show how many posts they have made.Add Before
Code: [Select]
// 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
« Last Edit: December 23, 2004, 01:27:57 PM by Jerry »
- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Showing the user's age beside thier post
« Reply #1 on: December 21, 2004, 05:14:45 AM »
Code: [Select]
// 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]

Offline Jerry

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,903
  • Gender: Male
  • What? I can't hear you over my awesomeness!!
    • PlanetSMF
Re: Showing the user's age beside thier post
« Reply #2 on: December 23, 2004, 01:28:42 PM »
formatted like yours :)
- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

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

Offline homeslice

  • Jr. Member
  • **
  • Posts: 183
  • Gender: Male
  • Usin' braincells as dippin' sauce
    • Wordabuse
Re: Showing the user's age beside thier post
« Reply #3 on: December 24, 2004, 02:43:35 PM »
I entered the code where u said to and nothing changed  ???

http://battle.ne1.net

Wordabuse Hip-Hop Forums!


Offline Jerry

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,903
  • Gender: Male
  • What? I can't hear you over my awesomeness!!
    • PlanetSMF
Re: Showing the user's age beside thier post
« Reply #4 on: December 24, 2004, 05:48:49 PM »
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."

Offline homeslice

  • Jr. Member
  • **
  • Posts: 183
  • Gender: Male
  • Usin' braincells as dippin' sauce
    • Wordabuse
Re: Showing the user's age beside thier post
« Reply #5 on: December 25, 2004, 01:54:31 AM »
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!


Offline jaijaymama

  • Semi-Newbie
  • *
  • Posts: 36
Re: Showing the user's age beside thier post
« Reply #6 on: May 15, 2005, 01:30:07 PM »
How can you do this to display the member's location and date they joined the forum?

Offline A.M.A

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,133
  • Gender: Male
  • ..
Re: Showing the user's age beside thier post
« Reply #7 on: May 15, 2005, 02:15:21 PM »
use:
Code: [Select]
', $message['member']['registered'], '

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

Offline Senkusha

  • Full Member
  • ***
  • Posts: 625
  • Gender: Male
  • Embrace Your Destiny!
    • Ayeka's Bliss
Re: Showing the user's age beside thier post
« Reply #8 on: November 29, 2005, 10:50:59 AM »
Is there a way to display the date registered only (with no time)?

Offline beberlei

  • Semi-Newbie
  • *
  • Posts: 20
  • Gender: Male
Re: Showing the user's age beside thier post
« Reply #9 on: December 10, 2006, 02:31:16 PM »
Is there a way to display the date registered only (with no time)?

I'm also wondering if this is possible.

Offline jabop

  • Semi-Newbie
  • *
  • Posts: 21
Re: Showing the user's age beside thier post
« Reply #10 on: April 10, 2008, 03:08:16 PM »
$txt[470] does not work for SMF 2.0 Beta 3


Needs fixed, please

Offline rsw686

  • Sophist Member
  • *****
  • Posts: 1,008
    • The Reptile File
Re: Showing the user's age beside thier post
« Reply #11 on: April 17, 2008, 09:15:54 AM »
$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

Offline Fiery

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,209
  • Gender: Male
  • Community Builder
Re: Showing the user's age beside thier post
« Reply #12 on: June 16, 2008, 11:21:55 PM »
$txt['not_applicable']  worked correct?

Offline Hoochie Coochie Man

  • SMF Hero
  • ******
  • Posts: 5,135
  • Gender: Male
    • İstanblues.org
Re: Showing the user's age beside thier post
« Reply #13 on: August 31, 2008, 01:40:10 PM »
Thanks for the tip.
İnadına SMF 1.1.X

Offline NeedHelp

  • Newbie
  • *
  • Posts: 2
Re: Showing the user's age beside thier post
« Reply #14 on: October 23, 2008, 03:57:45 AM »
Is there a way to make it where only the Admin or mods can see the ages?

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Showing the user's age beside thier post
« Reply #15 on: December 02, 2008, 08:34:47 PM »
Do you still need help with this NeedHelp?
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline FlixyaFriend

  • Semi-Newbie
  • *
  • Posts: 18
    • samsung ue46c8000
Re: Showing the user's age beside thier post
« Reply #16 on: February 05, 2009, 02:35:02 PM »
thanks for the useful tip.