Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Mr. Pedram on March 31, 2013, 01:51:41 PM

Title: Birthdate On Registration
Post by: Mr. Pedram on March 31, 2013, 01:51:41 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3680)

Birthdate On Registration v1.0
Add Birthday date field on registration page!

Compatibility
SMF 2.0

Mod by: Mr. Pedram (http://www.simplemachines.org/community/index.php?action=profile;u=323252)


This mod is licensed under a CC BY-NC-ND 3.0 (http://creativecommons.org/licenses/by-nc-nd/3.0/)
Title: Re: Birthdate On Registeration
Post by: Shambles on March 31, 2013, 02:08:26 PM
FYI, it's spelt "Registration" ;)
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on March 31, 2013, 02:50:41 PM
Quote from: Shambles on March 31, 2013, 02:08:26 PM
FYI, it's spelt "Registration" ;)

Thanks for that, it was damn misspelling.
Title: Re: Birthdate On Registration
Post by: FireDitto on March 31, 2013, 10:21:22 PM
Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?
Title: Re: Birthdate On Registration
Post by: TheListener on March 31, 2013, 10:34:15 PM
Quote from: FireDitto on March 31, 2013, 10:21:22 PM
Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?

If you are on 2.04 then you can do that without the mod.
Title: Re: Birthdate On Registration
Post by: FireDitto on March 31, 2013, 10:51:45 PM
Quote from: Old Fossil on March 31, 2013, 10:34:15 PM
Quote from: FireDitto on March 31, 2013, 10:21:22 PM
Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?

If you are on 2.04 then you can do that without the mod.

I am. And you can? I don't see anything for it in the admin areas.
Title: Re: Birthdate On Registration
Post by: Arantor on March 31, 2013, 10:56:15 PM
/me would like to know what Fossil is referring to as well.
Title: Re: Birthdate On Registration
Post by: TheListener on March 31, 2013, 10:59:24 PM
If I am correct (hopefully) then look at Core Feature >> Advanced Profile Features.

Title: Re: Birthdate On Registration
Post by: Arantor on March 31, 2013, 11:01:24 PM
It's not an option in there. Nor is it an option in the calendar, nor in registration settings (even if you put a minimum age in)
Title: Re: Birthdate On Registration
Post by: TheListener on March 31, 2013, 11:02:47 PM
Rightio my apologies FireDitto.

/me should really get reaquainted with 2.0.4
Title: Re: Birthdate On Registration
Post by: FireDitto on March 31, 2013, 11:50:55 PM
Hehe, it's okay :)
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on April 01, 2013, 05:22:09 PM
Quote from: FireDitto on March 31, 2013, 10:21:22 PM
Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?

It's possible, with a little programming. I'll try, maybe on the first update.
Title: Re: Birthdate On Registration
Post by: FireDitto on April 02, 2013, 01:43:05 AM
Quote from: Mr. Pedram on April 01, 2013, 05:22:09 PM
Quote from: FireDitto on March 31, 2013, 10:21:22 PM
Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?

It's possible, with a little programming. I'll try, maybe on the first update.

That would be brilliant :D
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on April 06, 2013, 04:38:11 AM
Quote from: FireDitto on April 02, 2013, 01:43:05 AM
Quote from: Mr. Pedram on April 01, 2013, 05:22:09 PM
Quote from: FireDitto on March 31, 2013, 10:21:22 PM
Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?

It's possible, with a little programming. I'll try, maybe on the first update.

That would be brilliant :D

Well, here you go :)

Register.php

Code (Find) Select
// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
// Or birthdate parts...
elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);


Code (Replace With) Select
// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
// Or birthdate parts...
elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']) && !empty($_POST['bday3']))
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);


Code (Find) Select
'theme_vars' => array(),

Code (Add After) Select
'birthdate' => $_POST['birthdate'],




Subs-Members.php

Code (Find) Select
if (!empty($regOptions['check_reserved_name']) && isReservedName($regOptions['username'], 0, false))

Code (Add Before) Select
// Birthdate Checking!
if (empty($regOptions['birthdate']) || $regOptions['birthdate'] == '0000-00-00')
{
fatal_error('Birthday is a required field!',false);
}else{
$arr=split("-",$regOptions['birthdate']); // splitting the array
$mm=$arr[1]; // first element of the array is month
$dd=$arr[2]; // second element is date
$yy=$arr[0]; // third element is year
If(!checkdate($mm,$dd,$yy)){
fatal_error('The Birthday you entered appears to be invalid!',false);
}
}
        list($Y,$m,$d)    = explode("-",$regOptions['birthdate']);
        If ((date("md") < $m.$d ? date("Y")-$Y-1 : date("Y")-$Y) < $modSettings['coppaAge'])
        fatal_error('Sorry! You are too young.',false);


Code (Find) Select
'REALNAME' => $regOptions['register_vars']['real_name'],

Code (Add After) Select
'birthdate' => $regOptions['birthdate'],

Be sure you installed the MOD first.
Title: Re: Birthdate On Registration
Post by: FireDitto on April 12, 2013, 06:22:03 AM
Thank you!

Tested and works wonderfully.

Which file would I need to look in to find where it says Birthday so I could put (required) after it in brackets so people know? I attempted to edit the ./Themes/default/languages/Login.english.php , but it doesn't appear to be working :/
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on April 12, 2013, 10:41:09 AM
Quote from: FireDitto on April 12, 2013, 06:22:03 AM
Thank you!

Tested and works wonderfully.

Which file would I need to look in to find where it says Birthday so I could put (required) after it in brackets so people know? I attempted to edit the ./Themes/default/languages/Login.english.php , but it doesn't appear to be working :/

You'r welcome.

Hmmm... weird!
Because you need edit Login.english.php exactly.

Like this:

Code (Find) Select
$txt['dob'] = 'Birthdate:';
$txt['dob_month'] = 'Month (MM)';
$txt['dob_day'] = 'Day (DD)';
$txt['dob_year'] = 'Year (YYYY)';


Code (Replace) Select
$txt['dob'] = 'Birthdate (required):';
$txt['dob_month'] = 'Month (MM)';
$txt['dob_day'] = 'Day (DD)';
$txt['dob_year'] = 'Year (YYYY)';





if doesn't work, try this:

./Register.template.php

Code (Find) Select
<strong>', $txt['dob'], '</strong><br />

Code (Replace) Select
<strong>', $txt['dob'], ' ', $txt['dob_req'], '</strong><br />

./Login.english.php

Code (Find) Select
$txt['dob'] = 'Birthdate:';

Code (Add After) Select
$txt['dob_req'] = '(required)';
Title: Re: Birthdate On Registration
Post by: FireDitto on April 14, 2013, 10:25:35 PM
:/ I had to remove the requirement edits you made, because it won't let us create Sub Accounts as a result since Sub Accounts don't offer a birthdate option upon setting them up.
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on April 15, 2013, 02:57:34 AM
Quote from: FireDitto on April 14, 2013, 10:25:35 PM
:/ I had to remove the requirement edits you made, because it won't let us create Sub Accounts as a result since Sub Accounts don't offer a birthdate option upon setting them up.

Sorry, but i don't understand what you mean about Sub Accounts
did you mean Sub-Account mod?
Title: Re: Birthdate On Registration
Post by: FireDitto on April 15, 2013, 05:26:25 AM
I do, yes, sorry :)
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on April 15, 2013, 06:08:46 AM
Quote from: FireDitto on April 15, 2013, 05:26:25 AM
I do, yes, sorry :)

Oh that, yes it doesn't support sub accounts.
Title: Re: Birthdate On Registration
Post by: Hj Ahmad Rasyid Hj Ismail on September 09, 2013, 10:44:51 PM
Quote from: Mr. Pedram on April 06, 2013, 04:38:11 AM
Quote from: FireDitto on April 02, 2013, 01:43:05 AM
Quote from: Mr. Pedram on April 01, 2013, 05:22:09 PM
Quote from: FireDitto on March 31, 2013, 10:21:22 PM
Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?

It's possible, with a little programming. I'll try, maybe on the first update.

That would be brilliant :D

Well, here you go :)

Register.php

Code (Find) Select
// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
// Or birthdate parts...
elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);


Code (Replace With) Select
// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
// Or birthdate parts...
elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']) && !empty($_POST['bday3']))
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);


Code (Find) Select
'theme_vars' => array(),

Code (Add After) Select
'birthdate' => $_POST['birthdate'],




Subs-Members.php

Code (Find) Select
if (!empty($regOptions['check_reserved_name']) && isReservedName($regOptions['username'], 0, false))

Code (Add Before) Select
// Birthdate Checking!
if (empty($regOptions['birthdate']) || $regOptions['birthdate'] == '0000-00-00')
{
fatal_error('Birthday is a required field!',false);
}else{
$arr=split("-",$regOptions['birthdate']); // splitting the array
$mm=$arr[1]; // first element of the array is month
$dd=$arr[2]; // second element is date
$yy=$arr[0]; // third element is year
If(!checkdate($mm,$dd,$yy)){
fatal_error('The Birthday you entered appears to be invalid!',false);
}
}
        list($Y,$m,$d)    = explode("-",$regOptions['birthdate']);
        If ((date("md") < $m.$d ? date("Y")-$Y-1 : date("Y")-$Y) < $modSettings['coppaAge'])
        fatal_error('Sorry! You are too young.',false);


Code (Find) Select
'REALNAME' => $regOptions['register_vars']['real_name'],

Code (Add After) Select
'birthdate' => $regOptions['birthdate'],

Be sure you installed the MOD first.

This isn't part of the mod right? Will you make the requirement part of it?
Title: Re: Birthdate On Registration
Post by: smirre on November 26, 2013, 11:45:35 AM
Hello!

Can it be done to force people to enter dob in the registration for 2.0.6?
Tested your mod and it works, and I even tried your solutions but no luck with that part  :-\
It would be really nice of you if you can help me (and others) with this one. We are probably going
over to be an association and when thats done we gonna need dob, adresses, real names & phone-numbers
to be stored into the database to get allowance from Sverok (Swedish association). If you even can take this
to a higher level and fix all of this into one mod, many associations would be soooo thankful :laugh:

Many regards

Smirre
Title: Re: Birthdate On Registration
Post by: Westwegoman on April 17, 2014, 03:17:57 PM
Since it is not required on registration, how would I go about making it show up under the "Additional Information" section instead of the "Required Information" section on the registration page?
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on May 03, 2014, 07:38:03 AM
Quote from: Westwegoman on April 17, 2014, 03:17:57 PM
Since it is not required on registration, how would I go about making it show up under the "Additional Information" section instead of the "Required Information" section on the registration page?

sounds good

Quote from: smirre on November 26, 2013, 11:45:35 AM
Hello!

Can it be done to force people to enter dob in the registration for 2.0.6?
Tested your mod and it works, and I even tried your solutions but no luck with that part  :-\
It would be really nice of you if you can help me (and others) with this one. We are probably going
over to be an association and when thats done we gonna need dob, adresses, real names & phone-numbers
to be stored into the database to get allowance from Sverok (Swedish association). If you even can take this
to a higher level and fix all of this into one mod, many associations would be soooo thankful :laugh:

Many regards

Smirre

I'll update all my Mods soon, maybe on the next update i do this.
Title: Re: Birthdate On Registration
Post by: -Captain Ghost- on July 04, 2014, 03:36:29 AM
Thanks for this mod but instead of entering value can we have a dropdown like this mod http://custom.simplemachines.org/mods/index.php?mod=3118.

I tried using the code of drop down from http://custom.simplemachines.org/mods/index.php?mod=3118 but not succeeded.It looks like this

it is not in center.

Hope anyone will help.

Thanks
Title: Re: Birthdate On Registration
Post by: Tokzu on July 30, 2014, 07:27:56 PM
I've made the changes Mr. Pedram said for the birthday to be obligatory in the register (only don't edit the part of 'REALNAME' => $regOptions['register_vars']['real_name'],) and it works. ;)

Quote from: r4ll on July 04, 2014, 03:36:29 AM
Thanks for this mod but instead of entering value can we have a dropdown like this mod http://custom.simplemachines.org/mods/index.php?mod=3118.

I tried using the code of drop down from http://custom.simplemachines.org/mods/index.php?mod=3118 but not succeeded.It looks like this

it is not in center.

Hope anyone will help.

Thanks

Code (Search in Register.template.php) Select
//Show Birthday
global $txt;
echo '
<dl class="register_form">
<dt>
<strong>', $txt['dob'], '</strong><br />
<span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
</dt>
<dd>
<input type="text" name="bday3" size="4" maxlength="4" value="', (!empty($context['member']['birth_date']) ? $context['member']['birth_date']['year'] : ''), '" /> -
<input type="text" name="bday1" size="2" maxlength="2" value="', (!empty($context['member']['birth_date']) ? $context['member']['birth_date']['month'] : ''), '" /> -
<input type="text" name="bday2" size="2" maxlength="2" value="', (!empty($context['member']['birth_date']) ? $context['member']['birth_date']['day'] : ''), '" />
</dd>
</dl>';


Code (Replace) Select
if (cache_get_data('intuitive_age', 120) != null)
$years = cache_get_data('intuitive_age', 120);
else
{
$years = array();
$base_year = 1904;
$current_year = date('Y');
$count = $base_year;
$age = 0;
$ages = array();

while ($count < $current_year)
{
++$count;
$years[] = $count;
}

$years = array_reverse($years);

foreach ($years as $year)
{
$ages[$year] = ++$age;
$year = array();
$year[$age] = $year;
}

cache_put_data('intuitive_age', $years, 120);
}

$days = array(
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31,
);

//Show Birthday
echo '
<dl class="register_form">
<dt>
<strong>', $txt['dob'], ':</strong><br />
<span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
</dt>
<dd>
<select name="bday1" id="bday1" style="padding: 4px;">
<option value="00" selected="selected">', $txt['calendar_month'], '&nbsp;</option>';

foreach ($txt['months_short'] as $key => $month)
echo '<option value="', $key, '">', $month, '</option>';

echo '
</select>
<select name="bday2" id="bday2" style="padding: 4px;">
<option value="00" selected="selected">', $txt['calendar_day'], '&nbsp;</option>';

foreach ($days as $day)
echo '
<option value="', $day, '">', $day, '&nbsp;</option>';

echo '
</select>';

if (!empty($years))
{
echo '
<select name="bday3" id="bday3" style="padding: 4px;">
<option value="0000" selected="selected">', $txt['calendar_year'], '&nbsp;</option>';

foreach ($years as $key => $year)
echo '<option value="', $year, '">', $year, '&nbsp;</option>';

echo '</select>';
}
else
echo '<input type="text" name="bday3" size="4" maxlength="4" value"', $context['member']['birth_date']['year'], '" class="input_text" />';

echo '
</dd>


Obviously after you have installed the mod. ;)
Title: Re: Birthdate On Registration
Post by: Mr. Pedram on August 01, 2014, 05:46:43 AM
Nice work.. Thanks :)
Title: Re: Birthdate On Registration
Post by: peterwaalker on August 22, 2014, 07:22:52 AM
Please is there a way I could handle this problem.
This mod helps to make members registration page more organised.
I set a configuration on my forum tthat only 14years and above will register.
But this mod is being deceived as a member just registered with 0000year 00month 00day. And it accepted him.
Is there anything I will do?
Title: Re: Birthdate On Registration
Post by: phpshiva on August 07, 2015, 01:57:37 PM
i have these errors


Undefined index: coppaAge

/Sources/Subs-Members.php
Regel: 540

and


Function split() is deprecated
/Sources/Subs-Members.php
Regel: 531

Any one?

i have SMF 2.0.10
Title: Re: Birthdate On Registration
Post by: pocttopus on June 02, 2020, 04:59:33 PM
Is there any chance to use this mod on 2.1rc2 without emulating?
It doesn't show up on register page.
Title: Re: Birthdate On Registration
Post by: Arantor on June 02, 2020, 05:07:57 PM
I think that's your answer; even with emulation it doesn't work because so much has changed in 2.1.
Title: Re: Birthdate On Registration
Post by: pocttopus on June 02, 2020, 06:05:41 PM
I like the changes of 2.1 but I miss all these mods.  :-\
Title: Re: Birthdate On Registration
Post by: Arantor on June 02, 2020, 06:53:58 PM
Quote from: pocttopus on June 02, 2020, 06:05:41 PM
I like the changes of 2.1 but I miss all these mods.  :-\

Then wait for 2.1 to be finished, then authors will update mods.
Title: Re: Birthdate On Registration
Post by: pocttopus on June 03, 2020, 04:39:35 AM
Oh... I'll wait... I hope I'm not going to be too old for 2.1 stable version.  ::)
Title: Re: Birthdate On Registration
Post by: si-biest on December 15, 2021, 08:03:19 AM
Quote from: Mr. Pedram on April 06, 2013, 04:38:11 AM
Quote from: FireDitto on April 02, 2013, 01:43:05 AM
Quote from: Mr. Pedram on April 01, 2013, 05:22:09 PM
Quote from: FireDitto on March 31, 2013, 10:21:22 PMOoh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?

It's possible, with a little programming. I'll try, maybe on the first update.

That would be brilliant :D

Well, here you go :)

Register.php

Code (Find) Select
// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
// Or birthdate parts...
elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);

Code (Replace With) Select
// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
// Or birthdate parts...
elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']) && !empty($_POST['bday3']))
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);

Code (Find) Select
'theme_vars' => array(),
Code (Add After) Select
'birthdate' => $_POST['birthdate'],


Subs-Members.php

Code (Find) Select
if (!empty($regOptions['check_reserved_name']) && isReservedName($regOptions['username'], 0, false))
Code (Add Before) Select
// Birthdate Checking!
if (empty($regOptions['birthdate']) || $regOptions['birthdate'] == '0000-00-00')
{
fatal_error('Birthday is a required field!',false);
}else{
$arr=split("-",$regOptions['birthdate']); // splitting the array
$mm=$arr[1]; // first element of the array is month
$dd=$arr[2]; // second element is date
$yy=$arr[0]; // third element is year
If(!checkdate($mm,$dd,$yy)){
fatal_error('The Birthday you entered appears to be invalid!',false);
}
}
        list($Y,$m,$d)    = explode("-",$regOptions['birthdate']);
        If ((date("md") < $m.$d ? date("Y")-$Y-1 : date("Y")-$Y) < $modSettings['coppaAge'])
        fatal_error('Sorry! You are too young.',false);

Code (Find) Select
'REALNAME' => $regOptions['register_vars']['real_name'],
Code (Add After) Select
'birthdate' => $regOptions['birthdate'],
Be sure you installed the MOD first.


Hello everyone

Problem, installed this mod, everything works, but when I configure the mandatory input of the date of birth, it gives an error Cfll to undefined -> function split ()
Title: Re: Birthdate On Registration
Post by: Shades. on April 05, 2022, 12:17:37 AM
I was able to get this mod to work on 2.1.1 clean install with no errors.

Instructions below. ;)

Backup your files and database first!!

Upload the mod and then you'll have to emulate it for 2.0.10.
Ignore the error and click on install.

Then open your Themes/default/Register.template.php...

Find:
<dl class="register_form" id="notify_announcements">
<dt>
<strong><label for="notify_announcements">', $txt['notify_announcements'], ':</label></strong>
</dt>
<dd>
<input type="checkbox" name="notify_announcements" id="notify_announcements" tabindex="', $context['tabindex']++, '"', $context['notify_announcements'] ? ' checked="checked"' : '', '>
</dd>
</dl>';

// If there is any field marked as required, show it here!

Add Before:
<dl class="register_form">
<dt>
<strong>', $txt['dob'], '</strong><br />
<span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
</dt>
<dd>
<input type="text" name="bday3" size="4" maxlength="4" value="', (!empty($context['member']['birth_date']) ? $context['member']['birth_date']['year'] : ''), '" /> -
<input type="text" name="bday1" size="2" maxlength="2" value="', (!empty($context['member']['birth_date']) ? $context['member']['birth_date']['month'] : ''), '" /> -
<input type="text" name="bday2" size="2" maxlength="2" value="', (!empty($context['member']['birth_date']) ? $context['member']['birth_date']['day'] : ''), '" />
</dd>
</dl>

That's it! 8)

You cannot view this attachment.

I don't know how to make the Birthdate Field "required" though! :(