Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Atoa on December 04, 2009, 06:54:18 AM

Title: Making Gender and Birthday required for register
Post by: Atoa on December 04, 2009, 06:54:18 AM
I want to make Gender and Birthday required for register.
I was able do add them to the register required fields by adding this code on the Register.template.php, bellow the allow email check box
<dt>
<strong>Sexo:</strong>
</dt>
<dd>
<select name="gender" id="gender" tabindex="8">
<option value="1" selected="selected">Masculino</option>
<option value="2" >Feminino</option>
</select>
</dd>

<dt>
<strong>Data de Nascimento:</strong><br />
<span class="smalltext">Ano (AAAA) - M&ecirc;s (MM) - Dia (DD)</span>
</dt>

<dd>
<input type="text" name="bday3" size="4" maxlength="4" value="1990" class="input_text" /> -
<input type="text" name="bday1" size="2" maxlength="2" value="00" class="input_text" /> -
<input type="text" name="bday2" size="2" maxlength="2" value="00" class="input_text" />
</dd>


Thanks in advance for any help
Title: Re: Making Gender and Birthday required for register
Post by: Acans on December 04, 2009, 08:22:42 AM

//GENDER
echo '
<tr>
<td width="40%">
<b>Gender:</b>
</td>
<td>
<input type="radio" name="gender" value="1" checked="checked" tabindex="', $context['tabindex']++, '" />Male<br />
<input type="radio" name="gender" value="2" tabindex="', $context['tabindex']++, '" />Female<br />
</td>
</tr>';


//AGE
echo '
<tr>
<td width="40%">
<b>Birthday</b> <br/>
<div class="smalltext">day - month - year</div>
</td>
<td>
<input type="text" name="bday2" size="2" maxlength="2" tabindex="', $context['tabindex']++, '" value="" /> -
<input type="text" name="bday1" size="2" maxlength="2" tabindex="', @$context['tabindex']++, '"value="" /> -
<input type="text" name="bday3" size="4" maxlength="4" tabindex="', @$context['tabindex']++, '" value="" />
</td>
</tr>';


Use at your own risk, you didn't state what SMF version your using. So I would make a backup of register.template.php before doing this.
Title: Re: Making Gender and Birthday required for register
Post by: JBlaze on December 04, 2009, 10:31:40 AM
If you are using SMF 2.0, you can use it's built-in custom profile fields to add these two fields to registration as well as make them mandatory. No need for template/source edits.

Admin -> Core Features -> Custom Profile Fields (enable)

Then go to Admin -> Features and Options -> Custom Profile Fields and set them up.
Title: Re: Making Gender and Birthday required for register
Post by: KensonPlays on December 04, 2009, 10:40:46 AM
yes, if possible, use SMF 2.0RC2, unless on a production site, as they say...
Title: Re: Making Gender and Birthday required for register
Post by: Atoa on December 04, 2009, 03:46:23 PM
Sorry for not stating which version i'm using. It's RC2

@JBlaze
I can't make this.
For gender there's no "required" field, only the option to show on registration, but it can be left blank.
And birthday isn't even showed on the Custom Profile Fields options.

@α¢αηѕ
I will give a try. I will edit the post if it's work

Edit:
The gender box worked fine, the way you did it's look far better, thanks
But the Birthday still can be left blank.
I want it to return a error if it's not filled and refuses the registration.

Edit 2:
I solved it. Instead of an type box, i will use an select box, so even if people ignore them, an bithday value will be added.
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 02, 2010, 08:53:19 AM
is there a way to link the newly created birthdates on the custom profile fields to the calendar ?
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 02, 2010, 10:13:57 AM
i tried alot but cant get what i want from the option describe above...

plz see the pic attached ... i want it to display something like that..

can someone tell how to make it look like that
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 02, 2010, 10:33:22 AM
thats a vbulletin feature. i m not sure its here for now.
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 02, 2010, 10:37:44 AM
so can u tell how to make B'day boxes for users to input their B'days in it at time of registration..

Also If users skips it registration will not proceed
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 02, 2010, 10:59:02 AM
what version of smf are you using ? because i just did it on my forum.

www.afrowall.com. Check the registration and see if thats what you want.
But i opted for just month and day . January 10. i believe people dont usual;y like to share their real year of birth {especially ladies.}
Title: Re: Making Gender and Birthday required for register
Post by: auto:blank on February 02, 2010, 11:43:42 AM
activating "Advanced Profile Fields" from core feature will make this possible.
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 02, 2010, 12:26:16 PM
im using RC2 ... like on ur forum www.afrowall.com

we have only one box for it .... can't we have 3 such drop down boxes ??

one containing months,other one days and last one year ...
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 02, 2010, 04:47:08 PM
You can create them on your own. on the custom profile, create a drop down for year. give it a name like Birth Year. and create drop down for it.
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 03, 2010, 12:16:27 AM
i've tried that already .... but try to think .... like i make a box for months containing all months .... then next box of year...

but problem comes at date ..i place count from 1 to 31...but

like January has 31 days ....

if someone chooses February then also he'll see 31 days (that will look absurd)

so thats the main problem
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 03, 2010, 03:38:34 AM
Quote from: sid2varun on February 03, 2010, 12:16:27 AM
i've tried that already .... but try to think .... like i make a box for months containing all months .... then next box of year...

but problem comes at date ..i place count from 1 to 31...but

like January has 31 days ....

if someone chooses February then also he'll see 31 days (that will look absurd)

so thats the main problem

HMM. TRUE. but i wouldnt mind if i were you.
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 03, 2010, 04:51:39 AM
so for now on im dropping this idea ..... if i get something i'll post it here for sure
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 04, 2010, 07:13:04 AM
i made it like this ... n values from here directly go into default B'day column in your profile ... :D
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 06, 2010, 06:39:17 AM
Quote from: sid2varun on February 04, 2010, 07:13:04 AM
i made it like this ... n values from here directly go into default B'day column in your profile ... :D

how did you do that man ?
Title: Re: Making Gender and Birthday required for register
Post by: InfoStrides on February 06, 2010, 11:38:17 AM
Quote from: sid2varun on February 04, 2010, 07:13:04 AM
i made it like this ... n values from here directly go into default B'day column in your profile ... :D

How did you do this? I am also interested.

Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 06, 2010, 12:17:04 PM
though i like the way i did mine.  i believe people dont really like to add the year of their birth on forums.
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 06, 2010, 12:26:06 PM
sorry for late response foks .... was bit ill

so here u go

/themes/default/Register.template.php

Find:
// If OpenID is enabled, give the user a choice between password and OpenID.


Add Before:
//Show Bday on reg

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>';



plz keep the original file as back up ;)
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 06, 2010, 12:55:47 PM
Its good but people might not like the idea of adding the birthday there.
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 06, 2010, 01:25:22 PM
its upto them its not a compulsion.... ;)
Title: Re: Making Gender and Birthday required for register
Post by: Afro on February 06, 2010, 01:30:02 PM
then you hat to write ''optional'' below it Just to indicate that. that would be nice
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on February 06, 2010, 01:49:12 PM
DOne ... thanx for the suggestion :)
Title: Re: Making Gender and Birthday required for register
Post by: chadon on November 27, 2010, 10:33:54 AM
I tried this mod on SMF: 2.0 RC3 but the text tags below are not showing on the registration page. Does anyone have any idea what I can replace them with? My forum is in French.

      <strong>', $txt['dob'], '</strong><br />
      <span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>


Update:

I checked the tags in the Profile.french.php file and they are the same as the ones on the mod so I don't understand what could be wrong. ???

$txt['dob'] = 'Date de naissance';

$txt['dob_month'] = 'Mois (MM)';

$txt['dob_day'] = 'Jour (JJ)';

$txt['dob_year'] = 'Année (AAAA)';


Update 2:

I don't know if I did the right thing but I added the text strings above in Modifications.french.php and it fixed my problem. I didn't notice any bug with either the registration page or the profile page with those strings in 2 language files but if someone has a better solution, let me know.  :)
Title: Re: Making Gender and Birthday required for register
Post by: SC RaceFan on March 14, 2011, 05:53:46 PM
I don't see how to make it a drop down. Oh, 2.0 RC5.  I went to your site and registered Afro and didn't see either field day or month.  I just went to the profile on here and it has Birthday.....some one needs to share LOL
Title: Re: Making Gender and Birthday required for register
Post by: sliverz on April 08, 2011, 12:13:52 PM
Ok, This works on the member registration, but not on administrator's new member registration.

As an administrator I already have a list of members I need to add and assign group member, their birthday, and maybe their avatars image.

So I need to do it from the admin page -> Members -> Register New Member.

Otherwise I have to update their profile after I add them. Which will be a lot of work. I'm looking for the fastest way to do this.

I noticed the fields smf use are : bday3 for year, bday1 for month, and bday2 for date. I tried to add these fields on the form and post it, but it doesn't work.

Any idea?
Title: Re: Making Gender and Birthday required for register
Post by: Joker™ on April 08, 2011, 12:23:30 PM
Quote from: SC RaceFan on March 14, 2011, 05:53:46 PM
I don't see how to make it a drop down. Oh, 2.0 RC5.  I went to your site and registered Afro and didn't see either field day or month.  I just went to the profile on here and it has Birthday.....some one needs to share LOL


Go to
Administration Center » Core Features >> Advanced Profile Fields (enable it)



Then go to
Administration Center » Features and Options » Profile Fields >> Add new field there and adjust options as per your liking.



Quote from: sliverz on April 08, 2011, 12:13:52 PM
Ok, This works on the member registration, but not on administrator's new member registration.

As an administrator I already have a list of members I need to add and assign group member, their birthday, and maybe their avatars image.

So I need to do it from the admin page -> Members -> Register New Member.

Otherwise I have to update their profile after I add them. Which will be a lot of work. I'm looking for the fastest way to do this.

I noticed the fields smf use are : bday3 for year, bday1 for month, and bday2 for date. I tried to add these fields on the form and post it, but it doesn't work.

Any idea?
That will require some coding, open a new thread someone might help you there, as this thread is already marked as solved.
Title: Re: Making Gender and Birthday required for register
Post by: Eclipse16V on December 25, 2011, 10:11:07 AM
Have any one this for SMF 2.0.2?

Thanks
Title: Re: Making Gender and Birthday required for register
Post by: drroot on January 27, 2012, 05:17:02 AM
Yes. same question here. Any more details?

How to use bday3-bday1-bday2 in good formated "Profile fields"?

Thanks.
Title: Re: Making Gender and Birthday required for register
Post by: Illori on January 27, 2012, 05:47:40 AM
please open a separate thread for your issue, this thread belongs to someone else and is marked solved. also please dont bump old threads.
Title: Re: Making Gender and Birthday required for register
Post by: dooie on May 29, 2012, 01:37:36 PM
Thank you for your information, I forgot to add the <dl></dl> open and close tags, now everything lines up.

Cheers.