Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 11:48:38 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155556 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: HowTo for adding custom fields to registration - INSIDE  (Read 2938 times)
felix_se_cat

Offline Offline

Posts: 45


« on: January 24, 2006, 02:17:21 AM »

hi,
i want to add some custom fields like 'birth date','phone','sex',... to the registration form.
ideas? is there already a tread for this problem (i didnt found one)?
thx!  afro
« Last Edit: January 26, 2006, 02:02:34 AM by felix_se_cat » Logged
felix_se_cat

Offline Offline

Posts: 45


« Reply #1 on: January 25, 2006, 12:37:00 PM »

cmon. no ideas?
Logged
glued2

Offline Offline

Posts: 20


WWW
« Reply #2 on: January 25, 2006, 12:54:12 PM »

It's not an easy one... 
You'll need to edit the sign up page, to include the items on the form, (html)
you'll need to then edit the page that processes the sign up form, to ensure you do something with that data (php)
assuming you want to put that data into the database, you'll have to add the fields to the database. (sql)
If you then want to view the data, you'll have to edit the user management page to display the extra fields. (php / html)
Most of it should just be a case of adding to stuff that is there already - but it's not a 2 second job...
Logged
felix_se_cat

Offline Offline

Posts: 45


« Reply #3 on: January 26, 2006, 01:51:38 AM »

thx glued2 for your reply.

i set work on my wb and added custom fields for user registration.
here is a small HowTo for others interested in adding custom fields:

1. open /account/signup_form.php
add your desired colums to the form. most suitable copy whole <tr> tag, replace e.g. '<?php echo $TEXT['EMAIL']; ?>' with e.g. 'your phone number: ', and use name="phone" in the <input>-tag in this example.

2. open /account/signup2.php
goto line 41: here after '$email = $admin->get_post('email');' add your fields with e.g.:  '$phone = $admin->get_post('phone');'
goto line 46: there you must add queries like: if($phone == "") { admin->print_error("fehler", $js_back); }
goto line 106 (note: the line numbers will change if you add code wink):
change:
$query = "INSERT INTO ".TABLE_PREFIX."users (group_id,active,username,password,display_name,email) VALUES ('$group_id', '$active', '$username','$md5_password','$display_name','$email')";
to e.g.
$query = "INSERT INTO ".TABLE_PREFIX."users (group_id,active,username,password,display_name,email,phone) VALUES ('$group_id', '$active', '$username','$md5_password','$display_name','$email','$phone')";

3. open /framework/class.login.php

goto line 164 and add lines like '$_SESSION['PHONE'] = $results_array['phone'];' there.

4. open /framework/class.wb.php
goto line 143 and add lines like:
// Get the current phone number
function get_user_phone() {
   return $_SESSION['PHONE'];
}

5. open /account/preferences_form.php

goto line 38, copy the whole <tr> tag, paste it below then modify the <input> tag to e.g.:
<input type="text" name="phone" style="width: 380px;" maxlength="255" value="<?php echo $admin->get_user_phone(); ?>" />

6. open /account/details.php
goto 30 line, there add a line like: $phone= $admin->get_post('phone');
goto line 42 and add 'phone' = '$phone' to the $query
goto line 50 and add '$_SESSION['PHONE'] = $phone;'

7. open your phpMyAdmin
add the required fields to your database in the table 'users' (i used varchar(255)) - in this example you must add the field 'phone'. sql-syntax: ALTER TABLE `users` ADD `phone` VARCHAR( 255 ) NOT NULL ;

note: i use wb 2.6.1 and i use the bugfix from this tread: http://forum.websitebaker.org/index.php/topic,2030.0.html
« Last Edit: January 26, 2006, 02:02:12 AM by felix_se_cat » Logged
glued2

Offline Offline

Posts: 20


WWW
« Reply #4 on: January 26, 2006, 03:04:12 AM »

nicely done!  Smiley
I'm sure people will find that useful. 
With any luck in WB3, we cat set custom fields  Smiley
Logged
felix_se_cat

Offline Offline

Posts: 45


« Reply #5 on: January 26, 2006, 03:10:40 AM »

yes, i hope so  wink
Logged
arwab

Offline Offline

Posts: 2


« Reply #6 on: May 27, 2006, 04:31:59 PM »

Thanx Felix you rock! This was so helpful I was looking around for a mod to do this but didn't find one so I was seconds away from diving into the code to see what needs to be modified to accomplish this but you did it for me. Thank you so much you saved me (and hopefully others) hours of work!

Even if it is not built in to the next version the ability to add an Extended User Preferences module would be great (as would other admin mods)!
Logged
RedRat

Offline Offline

Posts: 4


« Reply #7 on: October 28, 2007, 11:31:12 PM »

Any update for verison 2.6.7 on this??
Logged
RedRat

Offline Offline

Posts: 4


« Reply #8 on: October 30, 2007, 09:45:37 AM »

Anyone please huh  huh  huh

There are so many ppl on the forum asking about this... I've sent a pm to felix_se_cat  without any response undecided


Logged
doc
Guest
« Reply #9 on: October 30, 2007, 10:39:36 AM »

Hello,

there are no plans for integrating this feature to the existing WB 2.x core.
Maybe add your request to the thread proposals for WB 3.0.

Regards
Christian
Logged
Argos
Moderator
**
Offline Offline

Posts: 2161


WWW
« Reply #10 on: January 27, 2008, 02:15:04 PM »

I just finished modding my form using the clear instructions given. Thanks for that! It was a tedious job though, as I added 6 extra fields, and some files had been altered compared to the old version the instructions were written for. But it works like a charm. However, I do hope that some new version does have an easier way of doing this kind of stuff smiley
« Last Edit: January 27, 2008, 02:17:06 PM by Argos » Logged

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase: http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
Argos
Moderator
**
Offline Offline

Posts: 2161


WWW
« Reply #11 on: January 27, 2008, 10:54:06 PM »

I have a question about the newly added fileds. I want to make them compulsory, how can I do that?
Logged

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase: http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
xoanon

Offline Offline

Posts: 19


« Reply #12 on: November 24, 2008, 05:23:02 PM »

Hi,
How did you get the statement [2.  line 46] of your Orininal instruction below to work?
the default "if" condition for usernames & email does not work>> if($phone =="") {$wb-->print_error($MESSAGE['USERS']['MISSING_PHONE'], $js_back, false);}   also
based on your suggestion the following should work but it doesn't >> if($phone =="") {$wb-->print_error("Missing Phone", $js_back);}

I am getting a fatal error:  Fatal error: Call to undefined function print_error() in C:\wamp\www\wb\account\signup2.php on line xx

PS. if all values entered correctly the record is written onto the database, but error-handling is a problem.... ANY IDEAS?  I am using WB 2.7


------------------------------------------------------------------------------------------------------
From Original instructions:

2. open /account/signup2.php
goto line 41: here after '$email = $admin->get_post('email');' add your fields with e.g.:  '$phone = $admin->get_post('phone');'
goto line 46: there you must add queries like: if($phone == "") { admin->print_error("fehler", $js_back); }
« Last Edit: November 26, 2008, 02:09:46 AM by xoanon » Logged
madonna007

Offline Offline

Posts: 2


« Reply #13 on: November 25, 2008, 12:51:39 PM »

I'm sure people will find that useful.




.
Logged

Replica handbags
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!