News:

SMF 2.0.19 has been released! Please update. Read more.

Main Menu

Birthdate On Registration

Started by Mr. Pedram, March 31, 2013, 01:51:41 PM

Previous topic - Next topic

Mr. Pedram

Link to Mod

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

Compatibility
SMF 2.0

Mod by: Mr. Pedram


This mod is licensed under a CC BY-NC-ND 3.0
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

Shambles


Mr. Pedram

Quote from: Shambles on March 31, 2013, 02:08:26 PM
FYI, it's spelt "Registration" ;)

Thanks for that, it was damn misspelling.
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

FireDitto

Ooh, lovely! I do have a question, though! Would it be possible to make the birthday input required for registration?
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

TheListener

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.

FireDitto

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.
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Arantor

* Rainbow Dash would like to know what Fossil is referring to as well.

TheListener

If I am correct (hopefully) then look at Core Feature >> Advanced Profile Features.


Arantor

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)

TheListener

Rightio my apologies FireDitto.

* Old Fossil should really get reaquainted with 2.0.4

FireDitto

Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Mr. Pedram

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.
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

FireDitto

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
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Mr. Pedram

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.
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

FireDitto

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 :/
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Mr. Pedram

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)';
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

FireDitto

:/ 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.
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Mr. Pedram

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?
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

FireDitto

Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Mr. Pedram

My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

Hj Ahmad Rasyid Hj Ismail

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?

smirre

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

Westwegoman

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?

Mr. Pedram

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.
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

-Captain Ghost-

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

Tokzu

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. ;)
"I don't need a knight in a shinny armor, I need a angel in a trench coat"

My mods:

Mr. Pedram

My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

peterwaalker

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?

phpshiva

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

pocttopus

Is there any chance to use this mod on 2.1rc2 without emulating?
It doesn't show up on register page.

Arantor

I think that's your answer; even with emulation it doesn't work because so much has changed in 2.1.

pocttopus

I like the changes of 2.1 but I miss all these mods.  :-\

Arantor

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.

pocttopus

Oh... I'll wait... I hope I'm not going to be too old for 2.1 stable version.  ::)

si-biest

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 ()

Shades.

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! :(
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Advertisement: