We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Age in profile page. | Forum

Topic location: Forum home » Support » General Questions
Bjorn
Bjorn Nov 11 '10
I see that the "age" in profile page only show the date, not how many years the member is.

Here is how to modify this easy. (hope they can add this to the code.)

Inside the file date_time.php
at about line 402

Replace the public function "formatBirthdate".
With this.
(please rember to only replace this function, and backup file before any change is done, and if they don't add this to the project, you must do this when you update the code on next release.)

public static function formatBirthdate( $year, $month, $day )
{
$format = OW::getConfig()->getValue('base', 'date_field_format');

$result = '';
list($y, $m, $d ) = explode(':', date('Y:m:d', time()));

$age = $y - $year;

if ( $month > $m )
{
$age--;
}
else if ( ( $month == $m ) && ( $day > $d ) )
{
$age--;
}

if ( $format === 'dmy' )
{
$result = date("d M", mktime(0, 0, 0, $month, $day, $year)).' - age '.$age--.' years';
}
else
{
$result = date("d.m.Y", mktime(0, 0, 0, $month, $day, $year)).' - age '.$age--.' years';
}

return $result;
}
Den Team
Den Nov 15 '10
Thanks for suggestion Bjorn, but this feature is already present in oxwall. You can set type of display for birthdate field via Admin Panel->Users->Profile Question->edit birthdate field.
There are 3 options:
- date
- birthdate
- age
Crewdog
Crewdog Sep 9 '11
It would be nice if showing the age was not related to the birthday function because if user chooses to make birthday private, then you don't see the information. Lots of people still want to know accurate age. I think the only way to do this is to add a custom question and make it required.

Also, is there a way so that the system can be set to refuse anyone who is not 18? I have the year set to 1993, but for example, someone who is only 17 can still join (I tried it with a birthday of Oct 31, 1993 and it let me create profile). It would be good if the system would reject anyone not X number of years old, whatever age the Admin wanted to configure.
The Forum post is edited by Crewdog Sep 9 '11