Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: rcane on November 29, 2022, 10:17:46 AM

Title: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: rcane on November 29, 2022, 10:17:46 AM
I need custom field to collect members' dates of birth. 

However, I know mySQL has a specific format for Date values.

Since I need to calculate who is over a specific age, I'm guessing the format entered has to be in the sql DATE format--to do the math.

BUT, I know the users, and even with a description showing the proper format for the date I'll end up getting one in cuneiform.

So, is there something simple I'm overlooking or should I just go with a simple php/html page and tuck it in it's own table--requiring them to enter the birthdate using the clickable calendar in html?

Just looking for ideas to make it easy on both parties.
Title: Re: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: Kindred on November 29, 2022, 12:40:11 PM
1- SMF already has a birth date field as a fixed field in the profile.
2- SMF currently stores the data in that field as SQL type "date" which is yyyy-mm-dd

3. in order to do the same thing with custom profile fields, you would have to have 3 fields (year) (month) (day)
and probably choose a "select box" option...

However, a better choice would be to just change the code a little bit to require the defined birthdate field on registration.
template_profile_birthdate() is in profile.template.php
modify template_registration_form() in registration.template.php
to either add the function call or copy the contents into the reg form
Title: Re: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: rcane on November 29, 2022, 01:01:18 PM
I recall seeing, but I think I may have commented it out, because at the time there was a LOAD of confusion about who could see whose age (please, I get it, I really do).

Anyway, yeah, the custom profile field is the wrong way to go.  Too much work. 
I made a simple calendar input to start with that works fine and 'views' with the members table when I run a master query-- if I go that way.  But, if I can just use the stock birthdate (thanks for confirming it goes to the right date format; i did see that when poking around in the profile.template.) I'd rather go that route.

But, I can't find the registration.template.php--where is that?

profile.template.php looks fine and has nothing that I touched.  I'm not sure where I may have commented it out.
Title: Re: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: Shades. on November 29, 2022, 01:02:32 PM
I used this mod (https://www.simplemachines.org/community/index.php?topic=500869.msg4118916#msg4118916), however I couldn't figure out how to make it required!?
Title: Re: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: rcane on November 29, 2022, 01:27:04 PM
Did a search and found where I asked about removing that, last year.  Found the comment marks to remove and play with it.
Title: Re: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: Kindred on November 29, 2022, 01:29:28 PM
oops... I meant register.template.php
Title: Re: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: rcane on November 29, 2022, 01:55:19 PM
All good now. 
Title: Re: Need some guidance on custom profile field that's a birthdate + mySQL usage
Post by: Steve on November 29, 2022, 02:25:35 PM
Marking solved then.