1
CiberEspia
field for the age in register

how I can implement a field for the age in the registry (X 2.2).

Input - > date of birth.
Out: present age
identical a:http://72.29.75.243/~wwcncom/test2010/register.php (X 2.0.13)
Mario Burga
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>Adictoshp.org|Web Blog<<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2
McDonald
Re: field for the age in register
  • 2005/10/30 1:36

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


In the module Extended Profiles (select it from admin -> Modules) click on the Fields tab.
Here you can add a field to registry form by clicking Add Field.
From the Field Type you can choose Date.
I don't know how to get the age out of the selected date.

3
CiberEspia
Re: field for the age in register

It is easy to add additional fields but exactly what I need is the calculation of the age, that is the subject.
( show age in profile)
Mario Burga
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>Adictoshp.org|Web Blog<<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

4
CiberEspia
Re: field for the age in register

nobody???
Mario Burga
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>Adictoshp.org|Web Blog<<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

5
bb2120
Re: field for the age in register
  • 2005/11/1 18:12

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


why don't you ask the site's owner

6
m0nty
Re: field for the age in register
  • 2005/11/1 19:22

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


that's my test site ;)

in modules/profile/userinfo.php

$xoopsTpl->assign('lang_birth'_US_AGE);
$xoopsTpl->assign('user_age'CalcAge($thisUser->getVar('user_birth')));


then calcage is done through XOOPS root/include/functions.php

// ----------- added by m0nty for profile fields hack ----------------
function CalcAge($date_of_birth) { // YYYY-MM-DD
       
$cur_year=date("Y");
       
$cur_month=date("m");
       
$cur_day=date("d");            

       
$dob_year=substr($date_of_birth04);
       
$dob_month=substr($date_of_birth52);
       
$dob_day=substr($date_of_birth82);            
       
       if(
$cur_month>$dob_month || ($dob_month==$cur_month && $cur_day>=$dob_day) )
           return 
$cur_year-$dob_year;
       else
           return 
$cur_year-$dob_year-1;
   }    
// ----------- end of profile fields hack ----------------


although that's all for XOOPS 2.0.13 and 2.0.10 etc.. it will certainly need changing somewhat to work with 2.2.3 and i haven't had a look at how yet, but it should be simple enough. (don't forget the language definitions too)

7
m0nty
Re: field for the age in register
  • 2005/11/1 19:32

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


you will also have to edit the userinfo template too i think.. as i say i haven't got round to updating any hacks yet for 2.2 so i'm not certain..

but the smarty value would be >

<{$lang_birth}> for the language definition.
<{$user_age}> to display the calculated age result.

8
CiberEspia
Re: field for the age in register

but and how I do so that it appears in the registry???
Mario Burga
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>Adictoshp.org|Web Blog<<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

9
m0nty
Re: field for the age in register
  • 2005/11/3 4:35

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


i'm not exactly sure with XOOPS 2.2 as i haven't gotten round to looking into it that much.. i'm currently working on a full COPPA registration system for it.

you can create the date of birth field using extended profiles, but i'm not sure of how those variables are assigned to the userinfo page, as standard it would show the date of birth, so would need some editing somewhere to calculate the age from those results and use the calcage function..

you could hardcode that field in like with the 1 on my test site (but it's not a great method that i used, it could do with improving on the date input side instead of the calendar method) but that means hacking the module even more.. i'm trying to do these with as little hacking of core as possible to make it easier to implement and upgrade.

so far with the coppa registration i have done it with hacking only 1 XOOPS core file so far.. altho a couple of files in the profile module itself have needed hacking. but then the profile module itself was done that way to allow it to be modified etc.

if you give me some time i'll look into seeing how to do it for you..

Login

Who's Online

200 user(s) are online (119 user(s) are browsing Support Forums)


Members: 0


Guests: 200


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits