News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Making Gender and Birthday required for register

Started by Atoa, December 04, 2009, 06:54:18 AM

Previous topic - Next topic

Atoa

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

Acans


//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.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

JBlaze

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.
Jason Clemons
Former Team Member 2009 - 2012

KensonPlays

yes, if possible, use SMF 2.0RC2, unless on a production site, as they say...

Atoa

#4
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.

Afro

is there a way to link the newly created birthdates on the custom profile fields to the calendar ?

Joker™

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
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

thats a vbulletin feature. i m not sure its here for now.

Joker™

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
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

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.}

auto:blank

activating "Advanced Profile Fields" from core feature will make this possible.

Joker™

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 ...
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

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.

Joker™

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
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

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.

Joker™

so for now on im dropping this idea ..... if i get something i'll post it here for sure
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Joker™

i made it like this ... n values from here directly go into default B'day column in your profile ... :D
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

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 ?

InfoStrides

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.


Afro

though i like the way i did mine.  i believe people dont really like to add the year of their birth on forums.

Joker™

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 ;)
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

Its good but people might not like the idea of adding the birthday there.

Joker™

Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

then you hat to write ''optional'' below it Just to indicate that. that would be nice

Joker™

#24
DOne ... thanx for the suggestion :)
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

chadon

#25
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.  :)

SC RaceFan

#26
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
If I knew what I was doing, I would not be here asking question!  If I were a programmer, I would not need you!

sliverz

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?

Joker™

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.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Eclipse16V

I worked with:
SMF 2 in German

Shop:
SID Giessen

drroot

Yes. same question here. Any more details?

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

Thanks.

Illori

please open a separate thread for your issue, this thread belongs to someone else and is marked solved. also please dont bump old threads.

dooie

Thank you for your information, I forgot to add the <dl></dl> open and close tags, now everything lines up.

Cheers.

Advertisement: