PDA

View Full Version : Member's Age in Postbit & Getinfo Profile (automatically calculated from birthday)


Erwin
08 Aug 2002, 02:10
Member's Age in Postbit & Getinfo Profile - by Dr. Erwin Loh
--------------------------------------------------------------------------

I requested this a while back. Since no one has released a hack like this, I worked out how to do it.

NOTE: This hack automatically shows the age of the person calculated from the birthday entered (it's not a separate input). If there is no birthdate or birthyear, the age doesn't show up automatically.

1) Postbit hack
-------------------

This hack basically places the member's age underneath his join date (or wherever you want) in the postbit, like this:


Registered: July 2000
Age: 18
Location: USA
Posts: 102


If the member has not entered his birth-year, then the age will NOT show up at all, like this:


Registered: July 2000
Location: USA
Posts: 102


This hack requires 1 file edit (functions.php), and 1 template edit (postbit).

2) Getinfo Profile hack
----------------------------

This adds the member's age in their profile.

I've added this to the installation text file. It's a matter of editing members.php and the getinfo template.

Installation text file here:

Erwin
08 Aug 2002, 02:18
Also, this doesn't add any additional queries to your forums. :)

Deska
08 Aug 2002, 03:00
Nice hack man, thank's...

Schorsch
08 Aug 2002, 04:20
Thank you Erwin!!

useful hack and very easy installation :)

cu
Schorsch

Erwin
08 Aug 2002, 04:21
I updated the code - there was a bug in the original installation file - please clear your cache and view the new code now. :)

Vile
08 Aug 2002, 06:23
Awesome hack. Installed it, works like a charm:)

Floris
08 Aug 2002, 07:45
Installed, works very nice. So easy to add. And I am happy it doesn't add another query.

Unknown553
08 Aug 2002, 08:19
Awesome hack man. *installed*

[D]Vincent
08 Aug 2002, 08:34
I wouldn't say it's awesome, I don't see what's so great about displaying the user's age, of course I'm admin of a FF site so that wouldn't interest me. Nice job though.

Vile
08 Aug 2002, 09:22
Originally posted by [D]Vincent
I wouldn't say it's awesome, I don't see what's so great about displaying the user's age, of course I'm admin of a FF site so that wouldn't interest me. Nice job though.

Good point, but in that case, couldn't you say the same thing about a users post count, location, etc? :)

Erwin
08 Aug 2002, 14:39
Okay, I've updated the hack again, this time for the LAST time. I had to modify the hack because certain members had their ages off by 1 year.

Thanks to Boofo, who PMed me with a suggestion - I have incorporated his suggestion into my hack, and this has fixed up the age problem for certain members.

The hack should be working 100% now. :)

To upgrade, just download the text installation file, and replace the code in the functions.php with the new code.

Erwin
08 Aug 2002, 15:00
I had to fix 2 small bugs to do with birthdates with my update - The bug concerns members' birthdays which fall before 1970. I was wondering why there was a 54 year old on my site who insisted he was 53. :) According to Boofo, someone posted a fix on vb.com, and he PMed it to me. I've fixed this.

Birdie501
08 Aug 2002, 15:04
can you tell us which dates causes this errors?

Erwin
08 Aug 2002, 15:09
Originally posted by Birdie501
can you tell us which dates causes this errors?

I suspected it was certain months, but it appeared to be fairly random - I tried to find a pattern with my members, but couldn't. Whatever date they had trouble with, when I applied it to my profile, it still worked for me with my old code, but not for them.

Anyway, the latest code in my hack works with no problems at all - whatever it is, the new code fixed it.

So just use the latest installation text file, and there should be no more problems.

Sketch
08 Aug 2002, 19:21
I can see the older folks on my board going crazy on me if I installed this. ;) It's a great idea though.

Aaron

Velocd
09 Aug 2002, 01:11
For an anime forum like mine, I'm all for it ;)
Heh, it'll be funny to see the attitude of some people change once knowing they are younger than others.

Good job Erwin *clicks install*


No more "what's your age" threads popping up every month. (and if they still do, god have mercy on the poor soul)

[D]Vincent
09 Aug 2002, 02:25
Originally posted by Knightmare


Good point, but in that case, couldn't you say the same thing about a users post count, location, etc? :)

I don't display location either, I only display Posts, Online Stats, and Member ID, everything else is RPG related. Posts because members like to see how many posts they have and compete with their friends on the board sometimes. Online Stats because I belief people would like to see if someone is online or not. Member ID because I like to be able to see that I was the first person registered XD no not really I just like to see each member's ID.

ZiRu$
09 Aug 2002, 14:25
dope......i shall install this

LordHelmut
10 Aug 2002, 07:23
Nice man, that was the first hack I have ever installed. I got it to work with very little effort. I have been studying the actual PHP that goes in the functions.php but I dont understand it. Im trying to learn but im so confused. Well, thanks for the hack, its awesome :)

ZiRu$
14 Aug 2002, 01:54
Installed on 2.2.6 PERFECTLY.....thx

Mr. X
20 Aug 2002, 06:17
Great, just installed it.

NSeXcellent
23 Aug 2002, 16:37
Hmm.. i installed it, but nothing shows up. I've gone back over it 4 times to make sure its right. Still nothing.. any clue?

DrkFusion
23 Aug 2002, 16:43
Nice Work Erwin, thanks :)

Erwin
23 Aug 2002, 16:52
Originally posted by NSeXcellent
Hmm.. i installed it, but nothing shows up. I've gone back over it 4 times to make sure its right. Still nothing.. any clue?

Did you put $age in your postbit? It works if you follow the instructions closely...

eXtremeTim
24 Aug 2002, 00:49
Not bad. Nice and simple. I will proble also install this one once i get my site back up and running. :)

NSeXcellent
24 Aug 2002, 13:39
Originally posted by Erwin


Did you put $age in your postbit? It works if you follow the instructions closely...

Of course. Its only 2 steps. How could I forget that. :) I'll figure it out. I couldnt have screwed up TOO much :)

PsYc
24 Aug 2002, 15:40
cann someone help me with this code?

i have this in my member.php

to show the userage in members profile but when i view several profiles they are older than their birthday is

---------------------------

// Set userage !
if ($bbuserinfo[birthday] == '0000-00-00') {
$userage = "N/A";
} else {
if (date("Y")<$bday[0] or $bday[0]<1901 or $bday[0]=='0000') {
$userage = "N/A";
}
}

if ( ($userage!="N/A") ){
if (date("m")>=$bday[1] and date("d")>=$bday[2]) {
$userage=(date("Y")-$bday[0]);
eval("\$getinfo_userage = \"".gettemplate("getinfo_userage")."\";");
} else {
$userage=(date("Y")-$bday[0])+1;
eval("\$getinfo_userage = \"".gettemplate("getinfo_userage")."\";");
}

}


if ( ($userage!="N/A") ){
if (date("m")>=$bday[1] and date("d")<=$bday[2]) {
$userage=(date("Y")-$bday[0]);
eval("\$getinfo_userage = \"".gettemplate("getinfo_userage")."\";");
} else {
$userage=(date("Y")-$bday[0])+1;
eval("\$getinfo_userage = \"".gettemplate("getinfo_userage")."\";");
}

}

if ( ($userage!="N/A") ){
if (date("m")<=$bday[1] and date("d")<$bday[2]) {
$userage=(date("Y")-$bday[0])-1;
eval("\$getinfo_userage = \"".gettemplate("getinfo_userage")."\";");
} else {
$userage=(date("Y")-$bday[0]);
eval("\$getinfo_userage = \"".gettemplate("getinfo_userage")."\";");
}

}

--------------------------------------------

Birthday: 23.09.1982
Age: 20


^^ you see? he is older but its still August right? :)

anyone who knows how to fix this?

N9ne
24 Aug 2002, 19:52
I found something wrong!

A user set his birthdate to be in 1969 and it says he's 84 in the postbit :confused:

N9ne
24 Aug 2002, 19:55
ok Very strange I just checked his full profile in adminCP:

1918-06-12

That's what's set for his birthdate which means the 84 is RIGHT but in his PROFILE it says 1969, why does it say that :confused:

Erwin
25 Aug 2002, 08:47
Code removed from this post, and added to the TEXT installation file.

Erwin
25 Aug 2002, 08:50
Originally posted by Tha Rock
ok Very strange I just checked his full profile in adminCP:

1918-06-12

That's what's set for his birthdate which means the 84 is RIGHT but in his PROFILE it says 1969, why does it say that :confused:

That's weird, and has nothing to do with my hack. :) Looks like somewhere along the line something went wrong. My hack just displays the member's age - it doesn't touch the database or make a query.

PsYc
25 Aug 2002, 09:41
thanks erwin, for the fix works now :)

Erwin
25 Aug 2002, 10:19
You're welcome. :)

Intex
27 Aug 2002, 14:40
Great hack, was looking for something like that. Do you know how I can show this on a members page that's outside of vB?

Erwin
27 Aug 2002, 20:35
Originally posted by Intex
Great hack, was looking for something like that. Do you know how I can show this on a members page that's outside of vB?

Outside of vB? That's going to take a major rework of the code (remember, this code uses no queries). I don't know... anyone has any idea?

PHiXTiT
07 Sep 2002, 12:11
Great work! (INSTALLED)

Thanks:)

PHiXTiT
07 Sep 2002, 16:38
Just noticed that after installing this I had to move the admin/functions.php to a different area within as i lost the profile option in my postbit. No bigee, works great! Thanks:)

Erwin
07 Sep 2002, 22:16
Originally posted by PHiXTiT
Just noticed that after installing this I had to move the admin/functions.php to a different area within as i lost the profile option in my postbit. No bigee, works great! Thanks:)

I have no idea what you just said there, but whatever it is, it's not because of this hack - this hack is placed in the place in functions.php that decides what to put in the postbit - the code of the hack itself is just a simple mathematical calculation that uses up no database query and does not interfere with any other lines of code in functions.php - unless you have another hack in functions.php that uses the same variables.

Bottom line - this hack works fine with no problems - the problem you had (whatever it is) is not because of this hack.

PHiXTiT
08 Sep 2002, 02:19
Well this was the first hack I installed on a clean 2.2.7 board and when modifying the admin/functions.php I lost the profile button on my postbit. I retried it a couple times and same thing.
So I bumped the area to be pasted a couple lines up and all is working great now.
Just so you know my postbit template is highly modified just for looks.
I was just pointing this out so that if others are having any problems in 2.2.7 to try what i did.
Great hack though, comes in handy. :)

Buddha
12 Sep 2002, 16:20
um... i know this is a simple hack, but i'm getting this error...

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fulldvdr/public_html/admin/functions.php on line 929

Fatal error: Call to undefined function: vbdate() in /home/fulldvdr/public_html/admin/sessions.php on line 403

line 929 is

$buffer = str_replace(""", "\"", $buffer);

and line 203 in sessions is the last line in this quote

// get formatted date/time
if ($bbuserinfo['lastvisit']) {
$bbuserinfo['lastvisitdate'] = vbdate($dateformat." ".$timeformat,$bbuserinfo['lastvisit']);

???

Erwin
12 Sep 2002, 20:33
Well, I can guarantee that this error is not from my hack, but from your mistake, either in applying this hack, or in upgrading to 2.2.7 or some other thing you did. :) Like you said, this hack is as simple as it gets. You can basically uninstall this hack, and do it again, or try this.

Find this bit of code (basically what you posted in your post at the end):



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Add this right underneath:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



See if that works. You may have forgotten to close a function somewhere.

Buddha
12 Sep 2002, 22:39
thanks erwin... naw, it's closed up... i just posted those three lines to show which line had the error.

i know it's not your hack (it's unbelievably easy), but thought that maybe you (or someone else) might know.

thanks anyway.

edit... did the file modifications at home and it worked. must have had something to do with the browser based cp that i was using to do the hack at work, cause i did it three times (being very careful) and each time got the same result... ah well, works now... that's all that mattters. thanks.

*clicks installed*

PHiXTiT
13 Sep 2002, 00:28
It worked just fine for me (the users age and all) Except I lost the profile button in my postbit.
For those of you that may run into the same problem here is what I did instead of what was stated to do with the admin/functions.php to solve this issue, I did the following and all is working great on my 2.2.7 Board!

### Open admin/functions.php ###

### Find ###


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


### After add ###


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


### Save and Close admin/functions.php ###

NuclioN
15 Sep 2002, 17:35
I've found a simple script to echo Roman numbers, i'll attach it.

maybe you can let this work with this mod, would be great. :)

Erwin
15 Sep 2002, 23:23
Mmm... I'll have a look... but wouldn't it be a hassle for members to have to work out what the Roman numerals stand for? My age is VIIVMXCII... ??? :D

NuclioN
16 Sep 2002, 01:07
Fun Erwin ;)

\ \ - Speedy - / /
15 Oct 2002, 03:07
I noticed something, with the Age in the profile thingy, it says

Age: Age:16


How can I make it say


Age: 16


?


Thankx

Erwin
15 Oct 2002, 03:10
Oops.

In members.php, find:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Replace with:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



This fix only affects this hack if you put it in your Member Profile as in this post (which I've fixed):

http://www.vbulletin.org/forum/showthread.php?s=&postid=290103#post290103

The hack for the postbit remains unchanged, and works. :)

sunrunner_pei
21 Jan 2003, 19:07
Installed and working on 2.2.9! Excellent!

Tungsten
05 Jun 2003, 15:43
How would I go about adding this to the Admin CP so that when I edit a user's profile I can see their age calculated next to where it shows their birthdate? :D

Buczilla
18 Jun 2003, 01:21
Thanks a lot, great hack!

insanctus
23 Jun 2003, 06:20
~ clicks install..... I have plans for this :)

FWF
10 Jul 2003, 04:35
installs

Oblivion Knight
18 Jul 2003, 12:30
Erwin, is there any way to make $age = "Age: $userage<br>"; template controlled without the queries shooting up?

I did it like this:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

But it added many many more queries on top of the usual (obviously, it requires that template everytime a birthday is shown).. I looked for a $templatesused variable, but there isn't one in admin/functions.php.. I'm still learning how to do these basic things, sorry!

Many thanks,
Oblivion Knight.

Erwin
18 Jul 2003, 13:39
Add

age

to the $templatesused="

section in showthread.php under the POSTBIT section. :)

Oblivion Knight
18 Jul 2003, 18:10
Today at 02:39 PM Erwin said this in Post #55 (http://www.vbulletin.org/forum/showthread.php?postid=418688#post418688)
Add

age

to the $templatesused="

section in showthread.php under the POSTBIT section. :) Do I keep my code AND follow your step?
I tried this and the queries still stay much higher than they were before.

It doesn't help that I'm not feeling well at the moment I guess.. :sleep:

Erwin
19 Jul 2003, 04:40
There are 2 templatesused="

in showthread.php

Put that template "age" in both of them and see if it helps. Yes, you need to use your code for templates to be used. By caching the template, you should not incur any queries at all. It can be done.

Oblivion Knight
21 Jul 2003, 10:49
Well I'll be.. I could have sworn I tried that. :p
Until the new template is added, the queries stay higher than they should be (probably something I forgot last time). Then once it's added, the queries return to normal.

Erwin
21 Jul 2003, 12:42
Glad to know it works, and it does not add any queries. :)

Red Blaze
03 Oct 2003, 16:00
Added this hack a while back. Works great and like someone said above, I too have plans for this. ^^;;

PAINTBALLM
07 Oct 2003, 09:50
installed, thanks!

patriciafrankie
12 Oct 2003, 00:39
Awesome hack! I'm having a problem installing it on one of my themes, though. I have everything entered in correctly, but I still get Age: Age: 21.

I have no idea why it's doing this. Any suggestions?

Patricia

Erwin
12 Oct 2003, 05:02
Awesome hack! I'm having a problem installing it on one of my themes, though. I have everything entered in correctly, but I still get Age: Age: 21.

I have no idea why it's doing this. Any suggestions?

Patricia
Just edit your posbit and remove "Age:".

patriciafrankie
12 Oct 2003, 07:15
Thank you so much! :D I have another question: when I remove Age: from the postbit, I have a space in between the edge of the table/box and the letter "A" I've been wracking my brain all night trying to fix it :(

Patricia

I took the "Age:" part out, and doing so messes up the way it should look on the forum as far as colors go.

Here's a picture of the second "Age:" and a pic of it removed. Removing it changes the colors :(

Erwin
13 Oct 2003, 02:25
Try removing Age: from the code then. It's one or the other, you can't have it in the code and the template. :)

007
23 May 2004, 00:06
What changed in this for VB3? I thought it would work just find but it didn't. What needs to be changed for it to work? Thanks.

Boofo
23 May 2004, 02:24
What changed in this for VB3? I thought it would work just find but it didn't. What needs to be changed for it to work? Thanks.vB3 has the age in postbit built-in and I released an Age in Profile hack for vB3. ;)

ZiRu$
01 Aug 2004, 07:09
Installed and working on vb 2.3.5

TeenageWorld
06 Aug 2004, 22:23
I like this hack, so that's why I installed it, easy install.

- Teenage World

/me click's install