News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Custom Registration and Profile fields

Started by Aravot, March 06, 2005, 06:23:50 PM

Previous topic - Next topic

Aravot

I followed this tutorial, http://unknown.network32.net/tutorial.smf_custom-profile and created two custom registration fields (First Name & Last Name), the inputted info would also show in user "Profile", I created the same custom text fields (First Name & Last Name) in "Forum Profile Information" to unable my current member to write their Name and Last Name.

Everything works fine, but have two question.

Q1. I want to make the two created fields (First Name & Last Name) mandatory during registration, how can I achieve that, any help is appreciated, below is the code

Registration.template.php

</tr><tr>
<td width="40%">
<b>First Name:</b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
<td>
<input type="text" name="default_options[text_first_name]" size="20" value="', isset($context['member']['options']['text_first_name']) ? $context['member']['options']['text_first_name'] : '','"/>
</td>
<tr>
</tr><tr>
<td width="40%">
<b>Last Name:</b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td>
<input type="text" name="default_options[text_last_name]" size="20" value="', isset($context['member']['options']['text_last_name']) ? $context['member']['options']['text_last_name'] : '','"/>



Profile.template.php - dispaly Name & Last Name

</tr><tr>
<td><b>First Name: </b></td>
<td>', isset($context['member']['options']['text_first_name']) ? $context['member']['options']['text_first_name'] : '', '</td>
</tr><tr>
<td><b>Last Name: </b></td>
<td>', isset($context['member']['options']['text_last_name']) ? $context['member']['options']['text_last_name'] : '', '</td>


Profile.template.php - input box for Name & Last Name

</tr><tr>
<td width="40%"><b>First Name: </b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
<td><input type="text" name="default_options[text_first_name]" size="50" value="',isset($context['member']['options']['text_first_name'])? $context['member']['options']['text_first_name'] : '', '" /></td>
</tr><tr>
<td width="40%"><b>Last Name: </b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td><input type="text" name="default_options[text_last_name]" size="50" value="',isset($context['member']['options']['text_last_name'])? $context['member']['options']['text_last_name'] : '', '" /></td>


Q2. what part does InstantMessage.template.php effect I added the code from the tutorial but couldn't find any difference from before adding the code.

Here is the site www.peterosipof.com/smf it's a test site so you can create account if you want
.

Louis

ad Q.1:
have a look here and adapt it to your needs: http://www.simplemachines.org/community/index.php?topic=11249

and if you found out where these values are stored in the DB, let me know
It is your mind that creates this world (Buddha)

Aravot

Ok, followed the link read all the topics, but still can't get it to work below is the code, what am I missing.

Register.php

Tried this no go
if (!isset($_POST['options']['text_first_name']) || $_POST['options']['text_first_name'] == '')
fatal_error('Please enter in your name to register.', false);


Tried this same result
if (!isset($_POST['text_first_name']) || $_POST['text_first_name'] == '')
fatal_error('Please enter your name to register.', false);

Louis

Pure guessing (as I don't have the time to test it right now):

Change Register.template.php from<input type="text" name="default_options[text_first_name]" size="20" value="', isset($context['member']['options']['text_first_name']) ? $context['member']['options']['text_first_name'] : '','"/>
to <input type="text" name="options[text_first_name]" size="20" />

and then use $_POST['options']['text_first_name']

BTW: The values are stored in the themes table as user-specific values (don't forget to check if they are stored at all)
It is your mind that creates this world (Buddha)

Aravot

Thanks Louis that worked.

My final code for custom registration with option in profile for current user to add the information, please do check and let me know if they are any errors before I implement it into my main website.

Registration.template.php

</tr><tr>
<td width="40%">
<b>First Name:</b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
         <td>
<input type="text" name="default_options[text_first_name]" size="20" />
</td>
<tr>
</tr><tr>
<td width="40%">
<b>Last Name:</b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td>
<input type="text" name="default_options[text_last_name]" size="20" />
</td>
<tr>


Profile.template.php - display Name & Last Name

</tr><tr>
      <td><b>First Name: </b></td>
          <td>', isset($context['member']['options']['text_first_name']) ? $context['member']['options']['text_first_name'] : '', '</td>
</tr><tr>
     <td><b>Last Name: </b></td>
          <td>', isset($context['member']['options']['text_last_name']) ? $context['member']['options']['text_last_name'] : '', '</td>


Profile.template.php - input box for Name & Last Name

</tr><tr>
        <td width="40%"><b>First Name: </b>
<div class="smalltext">', 'Birth name, Given name', '</div>
        </td>
<td><input type="text" name="default_options[text_first_name]" size="50" value="',isset($context['member']['options']['text_first_name'])? $context['member']['options']['text_first_name'] : '', '" /></td>
</tr><tr>
         <td width="40%"><b>Last Name: </b>
<div class="smalltext">', 'Surname, Family name', '</div>
         </td>
<td><input type="text" name="default_options[text_last_name]" size="50" value="',isset($context['member']['options']['text_last_name'])? $context['member']['options']['text_last_name'] : '', '" /></td>


source/Register.php
// If you're an admin, you're special ;).
if (!$user_info['is_admin'])
{

if (!isset($_POST['options']['text_first_name']) || $_POST['options']['text_first_name'] == '')
fatal_error('Please enter your name to register.', false);

if (!isset($_POST['options']['text_last_name']) || $_POST['options']['text_last_name'] == '')
fatal_error('Please enter your lastname to register.', false);


Aravot


[Unknown]

Quote from: Aravot on March 08, 2005, 03:17:25 PM
Registration.template.php

Register.template.php

Quote

</tr><tr>
<td width="40%">
<b>First Name:</b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
         <td>
<input type="text" name="default_options[text_first_name]" size="20" />
</td>
<tr>
</tr><tr>
<td width="40%">
<b>Last Name:</b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td>
<input type="text" name="default_options[text_last_name]" size="20" />
</td>
<tr>

You're using default_options here still.  That's fine, but if you use it here...

Quotesource/Register.php

Sources/Register.php

Quote
// If you're an admin, you're special ;).
if (!$user_info['is_admin'])
{

if (!isset($_POST['options']['text_first_name']) || $_POST['options']['text_first_name'] == '')
fatal_error('Please enter your name to register.', false);

if (!isset($_POST['options']['text_last_name']) || $_POST['options']['text_last_name'] == '')
fatal_error('Please enter your lastname to register.', false);

Quote

You have to use it there, too.  See the 'options' there?  And the default_options above that?  Pick one... but they both have to be the same.

-[Unknown]

Aravot

Thanks [Unknown],

What's the difference bettween 'default_options' vs 'options'.

[Unknown]

The first is for all themes, the second for just the current.  There is no difference during registration.

-[Unknown]

Aravot

OK here is the final code, hope it's correct, I tested it works.

QuoteRegister.php

// If you're an admin, you're special ;).
if (!$user_info['is_admin'])
{

if (!isset($_POST['default_options']['text_first_name']) || $_POST['default_options']['text_first_name'] == '')
fatal_error('Please enter your name to register.', false);

if (!isset($_POST['default_options']['text_last_name']) || $_POST['default_options']['text_last_name'] == '')
fatal_error('Please enter your lastname to register.', false);


QuoteRegister.template.php

</tr><tr>
<td width="40%">
<b>First Name:</b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
<td>
<input type="text" name="default_options[text_first_name]" size="20" />
</td>
<tr>
</tr><tr>
<td width="40%">
<b>Last Name:</b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td>
<input type="text" name="default_options[text_last_name]" size="20" />
</td>
<tr>


QuoteProfile.template.php

</tr><tr>
<td><b>First Name: </b></td>
<td>', isset($context['member']['options']['text_first_name']) ? $context['member']['options']['text_first_name'] : '', '</td>
</tr><tr>
<td><b>Last Name: </b></td>
<td>', isset($context['member']['options']['text_last_name']) ? $context['member']['options']['text_last_name'] : '', '</td>
<tr>


QuoteProfile.template.php

echo '
</tr><tr>
<td width="40%"><b>First Name: </b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
<td><input type="text" name="default_options[text_first_name]" size="20" value="',isset($context['member']['options']['text_first_name'])? $context['member']['options']['text_first_name'] : '', '" /></td>
</tr><tr>
<td width="40%"><b>Last Name: </b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td><input type="text" name="default_options[text_last_name]" size="20" value="',isset($context['member']['options']['text_last_name'])? $context['member']['options']['text_last_name'] : '', '" /></td>
<tr>

hfhs72

[unknown]

I have an additional question for you. I've followed your tutorials and the advise in the previous messages and all is working good. The data collected in the registration is outputing in the user profile just like it is supposed to.

My question:

The data that is collected in the registration can not be edited, correct? At least I can not find those fields in any of the database files. How would one go about finding and editing that data that is collected in the registration process.

For example, I have edited the register.template.php to ask for a real_name and edited the profile.templated.php file to output the data.  Everything shows up like it is supposed to. Where can I find that data that was stored?

Your help is greatly appreciated.

Don

Aravot

#11
Quote from: hfhs72 on May 08, 2005, 09:29:42 PM
My question:

The data that is collected in the registration can not be edited, correct?

Your help is greatly appreciated.

Don

If you want the data to be editable you need to add a similar code to Profile.template.php
QuoteProfile.template.php

echo '
</tr><tr>
<td width="40%"><b>First Name: </b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
<td><input type="text" name="default_options[text_first_name]" size="20" value="',isset($context['member']['options']['text_first_name'])? $context['member']['options']['text_first_name'] : '', '" /></td>
</tr><tr>
<td width="40%"><b>Last Name: </b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td><input type="text" name="default_options[text_last_name]" size="20" value="',isset($context['member']['options']['text_last_name'])? $context['member']['options']['text_last_name'] : '', '" /></td>
<tr>


Try it here http://orstio.armeniancollegeofcalcutta.com I have created a custom registration it asks for user name and lastname, it displays the fields in user profile and can be changed in Forum Profile Information.

Use: test/test OR register you own it's a test site.

hfhs72

If you want the data to be editable you need to add a similar code to Profile.template.php
QuoteProfile.template.php

Thanks for the information. I've tried this out however I keep getting an error message. Where does this have to go in the profile.template.php file?


Aravot

What error message do you get? I put the code on line 100.

hfhs72

Quote from: Aravot on March 09, 2005, 11:24:02 PM
OK here is the final code, hope it's correct, I tested it works.

QuoteProfile.template.php

echo '
</tr><tr>
<td width="40%"><b>First Name: </b>
<div class="smalltext">', 'Birth name, Given name', '</div>
</td>
<td><input type="text" name="default_options[text_first_name]" size="20" value="',isset($context['member']['options']['text_first_name'])? $context['member']['options']['text_first_name'] : '', '" /></td>
</tr><tr>
<td width="40%"><b>Last Name: </b>
<div class="smalltext">', 'Surname, Family name', '</div>
</td>
<td><input type="text" name="default_options[text_last_name]" size="20" value="',isset($context['member']['options']['text_last_name'])? $context['member']['options']['text_last_name'] : '', '" /></td>
<tr>



Can you tell me where this code goes in the Profile.template.php goes? I've got everything working except I can not get the information to show up on the Forum Profile Information page for some reason.

Thanks Aravot

Aravot

To display names in the profile you need to use the following code, the above code is for changing the names and should go after // Gender, birthdate and location around line 865, this code around line 100, hope is not confusing

QuoteProfile.template.php

</tr><tr>
<td><b>First Name: </b></td>
<td>', isset($context['member']['options']['text_first_name']) ? $context['member']['options']['text_first_name'] : '', '</td>
</tr><tr>
<td><b>Last Name: </b></td>
<td>', isset($context['member']['options']['text_last_name']) ? $context['member']['options']['text_last_name'] : '', '</td>
<tr>

hfhs72

I thought I would post all the code that I am using. All is working except for the last block of code. Whenever I put that in I get an error.

The registration is working fine. This is the code I have in the Register.php file:
if (!isset($_POST['default_options']['text_gradName']) || $_POST['default_options']['text_gradName'] == '')
fatal_error('Please enter your name to register.', false);


      if (!isset($_POST['default_options']['text_hsAttended']) || $_POST['default_options']['text_hsAttended'] == '')
fatal_error('Please enter your High School name to register.', false);

      if (!isset($_POST['default_options']['text_gradYear']) || $_POST['default_options']['text_gradYear'] == '')
fatal_error('Please enter your graduation year to register.', false);



This is the code I have in the Register.template.php file:

</tr><tr>
                       <td width="40%">
                       <b>Name at Graduation:</b>
                 <div class="smalltext">', 'First and Last name when you graduated', '</div>
                                 </td>
                           <td>
                 <input type="text" name="default_options[text_gradName]" size="30" />
                       </td>
                   <tr>


                            </tr><tr>
                       <td width="40%">
                       <b>High School Attended:</b>
                 <div class="smalltext">', '', '</div>
                                 </td>
                           <td>
                 <input type="text" name="default_options[text_hsAttended]" size="30" />
                       </td>
                   <tr>


                             </tr><tr>
                       <td width="40%">
                       <b>Graduation Year:</b>
                 <div class="smalltext">', 'If fauculty, year you left', '</div>
                                 </td>
                           <td>
                 <input type="text" name="default_options[text_gradYear]" size="10" />
                       </td>
                   <tr>
                         </td>



This is the code I have in the Profile.template.php file: (at about line 100)

</tr><tr>
                              <td><b>Name at Graduation: </b></td>
                              <td>', isset($context['member']['options']['text_gradName']) ? $context['member']['options']['text_gradName'] : '', '</td>

                   
                        </tr><tr>
                              <td><b>High School Attended: </b></td>
                              <td>', isset($context['member']['options']['text_hsAttended']) ? $context['member']['options']['text_hsAttended'] : '', '</td>                             

                        </tr><tr>
                              <td><b>Grad Year: </b></td>
                              <td>', isset($context['member']['options']['text_gradYear']) ? $context['member']['options']['text_gradYear'] : '', '</td>
                              <tr>



This code is in the Profile.template.php file under // Gender, Birthdate and Location. When ever I put this code in I get an error message that reads:

Template Parse Error!
There was a problem loading the /Themes/default/Profile.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.

echo '
</tr><tr>
<td width="40%"><b>Grad Name: </b>
<div class="smalltext">', 'Name at Graduation', '</div>
</td>
<td><input type="text" name="default_options[text_gradName]" size="30" value="',isset($context['member']['options']['text_gradName'])? $context['member']['options']['text_gradName'] : '', '" /></td>
</tr><tr>
<td width="40%"><b>High School Attended: </b>
<div class="smalltext">', 'Name of your High School', '</div>
</td>
<td><input type="text" name="default_options[text_hsAttended]" size="30" value="',isset($context['member']['options']['text_hsAttended'])? $context['member']['options']['text_hsAttended'] : '', '" /></td>
</tr><tr>
<td width="40%"><b>Graduation Year: </b>
<div class="smalltext">', 'Year you graduated high schooll', '</div>
</td>
<td><input type="text" name="default_options[text_gradYear]" size="30" value="',isset($context['member']['options']['text_gradYear'])? $context['member']['options']['text_gradYear'] : '', '" /></td>
<tr>


Please take a look at this and see if you can find what I am doing wrong.

Aravot


Aravot

#18
Updated to SMF 1.1 beta 4, I can't find the following code hence I don't know where to add my custom fields.

$sourcedir/Register.php can't find this code


// If you're an admin, you're special ;).
if (!$user_info['is_admin'])
{


Since I can't find the above code I don't know where to add the following code, any help hint is appreciated.

if (!isset($_POST['default_options']['text_first_name']) || $_POST['default_options']['text_first_name'] == '')
fatal_error('Please enter your Name to register.', false);

if (!isset($_POST['default_options']['text_last_name']) || $_POST['default_options']['text_last_name'] == '')
fatal_error('Please enter your Last Name to register.', false);

[Unknown]

#19
Put it before this:

// Set the options needed for registration.
$regOptions = array(


-[Unknown]

oldschr

I would like to do a very simple edit but it is proving more difficult than what it should be.  I would like to edit the $txt field for Location:  This is the forum I am working on hxxp:www.humsci.auburn.edu/forum [nonactive] .   I would like when user edit their Profile instead of it just saying "Location: " for it to say "Affiliation and Location".  This Forum is based off the Spaceman! Forum.
I am the sys Admin and this is a NEW server, less than a week old.

Any help would be greatly appreciated.

Chris

Aravot

oldschr,

In Themes/default/languages/index.english.php search for [227] and replace Location with Affiliation and Location

oldschr

Thanks, That did the trick.  Since I was using a modified Spaceman Theme never thought to look in the default folder location.  I looked just about everywhere except there, including in the mysql smf_ database. 

Thanks for the Help.
Chris

allever

Quote from: Aravot on March 06, 2005, 06:23:50 PM
I followed this tutorial, http://unknown.network32.net/tutorial.smf_custom-profile
anyone knows any other place where this tutorial is available?  This website seems to timeout for me.  Thank You.
Sometimes, it's the little features.. Err, things that matters....


residential

I am considering using SMF for our neighborhood website.  Registration and profile customization is very important because I'll need to make the memberlist a resident directory.   

I've been reading these posts and tutorials about customizing the registration and profile fields trying to see if it's possible to acheive my needs. 

On Registration I need the following:
1. To change the "Choose Username" text to "Last Name"
2. I then need to add a field "husband and wife's first names"
3. Add a field "Telephone Number"
4. Add a field "Address"

Important Needs:
*Need #2 to pull together with number #1 to make username (ie Smith, Jon and Sue). 
*Need Telephone number to show on memberlist instead of the 4 extra contact info such as AIM, etc...

Is this (or anything close) possible? 

I'd also like to say that SMF appears to be a stellar program compared to some of the others I've been looking into.  Kudos to the creators.

Deb

#26
I have done this hack and works very well except in one place. ( I use 1.1 RC2 )

I only use one field "fullname" everywhere like this:
<input type="text" name="default_options[profile_real_name]".......

It works when a user register and store the fullname.....it works for the user to edit in his/her profile.. it shows up when you check a user etc.

My problem is that I can't as Admin register a new member ( in Admincenter - members - Registration ) .... I can see the field "fullname" but it doesn't store the fullname.
It must be something I have overlooked or I am brain dead right now.... ::)

In Register.template.php I have put the code under this part, just under the field USERNAME:

<tr class="windowbg2">
<th width="50%" align="right">
<label for="user_input">', $txt['admin_register_username'], ':</label>
<div class="smalltext" style="font-weight: normal;">', $txt['admin_register_username_desc'], '</div>
</th>
<td width="50%" align="left">
<input type="text" name="user" id="user_input" size="30" maxlength="25" />
</td>


like this:

<tr class="windowbg2">
<th width="50%" align="right">
<label for="user_input">Full name:</label>
<div class="smalltext" style="font-weight: normal;">Write your FULLNAME here</div>
</th>
<td width="50%" align="left">
<input type="text" name="user" id="user_input[" size="30" maxlength="25" />
</td>


I have tried to put profile_real_name  in different places here ( in the code above):
<label for="user_input">      name="user"        id="user_input"

The problem must be here??  What shall I use for label, name and id ?

Hope I can get some help with this,, it makes me crazy  >:(

Thanks
Thank you from Deb :)

Deb

Sorry I have to "BUMP" this Topic up again but still hope for some help  :'( .

Seems I also need to involve the file  /Sources/ManageRegistration.php and in this code:

$regOptions = array(
'interface' => 'admin',
'username' => $_POST['user'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'password_check' => $_POST['password'],
'check_reserved_name' => false,
'check_password_strength' => false,
'check_email_ban' => false,
'send_welcome_email' => isset($_POST['emailPassword']),
'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing',
'memberGroup' => empty($_POST['group']) ? 0 : (int) $_POST['group'],
);

But what??
Thank you from Deb :)

paki

try this out.. by no means am i a PHP expert but logically it might work.. lol

find
'email' => $_POST['email'],

place after
'user' => $_POST['user'],

it looks like your FULLNAME field enters into the form as "user" in that code.. if thats not right try changing all those "user" fields to "fullname" and see if that does anything.. maybe?

edit: well it looks like that post was from a month ago.. but if you see it feel free to try it out.





i am also having a problem.. the users on my site register using the Joomla! module, and I would like the information they place in their registration form to be placed into the profile. Mainly I am looking at putting a "Make, Model, Year of your car" field in because my website/forum is vehicle oriented. I have placed a "Make Model Year of your car" field in the profile.template.php, and it shows up on the profile and everything perfectly for SMF. The problem I am having is how do I post it from Joomla!'s registration to the profile? I've tried a couple things and none seem to work.. the field it is named is default_options['profile_vehicle']
http://www.dfwhyundais.com <-- Dallas/Ft. Worth's Local Hyundai Group

KitTen55

Speaking of adding a field, does anyone know how to delete a custom field i.e ICQ, or MSN?

I tried deleting the code in default/profile.template.php but got errors. I've just started using SMF so a bit detail is required.

Thanks in advance for any help.

Advertisement: