Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

New user field system HOW TO

Asked Modified Viewed 48,254 times
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Started this discussions
  • Answered 11 questions
asked
Super Admin

As you in v6 it is difficult to add new user fields. Thanks to the new modular system in v7 it's now quite simple. No mdifications are required, but in order to add fields you have to create include files, these are stored in the folder includes/user_fields. There is a format to the construct of the filenames:

user_FIELD_include_var.php - carries the database field name & info
user_FIELD_include.php - controls input, display and data validation

If you want to have locale support you can create a file called user_FIELD.php and place it in the folder locale/langauge/user_fieds.

* replace the word field with the name of your field, e.g. user_skype_include_var.php

Lets suppose we're adding a skype field.

1. Create a locale file called user_skype.php which contains the following code:

<?php
// Field Name (appears in edit/profile and user field admin)
$locale['uf_skype'] = "Skype:";
// Description (appears in user field admin)
$locale['uf_skype_desc'] = "Skype Voice Communicator";
?>


2. Create a file called user_skype_include_var.php which contains the following code

<?php
if (!defined("IN_FUSION")) { die("Access Denied"); }

// Field display name
$user_field_name = $locale['uf_skype'];
// Field Description
$user_field_desc = $locale['uf_skype_desc'];
// The name of the database field used to ADD or DROP
$user_field_dbname = "user_skype";
// The group the field appears under; 1 = Contact, 2 = Information, 3 = Options and 4 = Statistics
$user_field_group = 1;
// The database properties used when ADDing the above field
$user_field_dbinfo = "VARCHAR(50) NOT NULL DEFAULT ''";
?>


3. With the admin side of things taken care of, now we need to handle input, display and data validation. Create a file called user_skype_include.php with the following code:

<?php
if (!defined("IN_FUSION")) { die("Access Denied"); }

if ($profile_method == "input") {
// Create the input field for registration and edit profile
echo "<tr>\n";
echo "<td class='tbl'>".$locale['uf_skype'].":</td>\n";
echo "<td class='tbl'><input type='text' name='user_skype' value='".(isset($user_data['user_skype']) ? $user_data['user_skype'] : "")."' maxlength='16' class='textbox' style='width:200px;' /></td>\n";
echo "</tr>\n";
} elseif ($profile_method == "display") {
// Create the display for the user profile
if ($user_data['user_skype']) {
echo "<tr>\n";
echo "<td width='1%' class='tbl1' style='white-space:nowrap'>".$locale['uf_skype']."</td>\n";
echo "<td align='right' class='tbl1'>".$user_data['user_skype']."</td>\n";
echo "</tr>\n";
}
} elseif ($profile_method == "validate_insert") {
// Validate the insert data field & value for our field
$db_fields .= ", user_skype";
$db_values .= ", '".(isset($_POST['user_skype']) ? stripinput(trim($_POST['user_skype'])) : "")."'";
} elseif ($profile_method == "validate_update") {
// Validate the update data value for our field
$db_values .= ", user_skype='".(isset($_POST['user_skype']) ? stripinput(trim($_POST['user_skype'])) : "")."'";
}
?>


Important points
#1 All user_field files must start with same name i.e. user_skype.
#2 The data field and input name must be the same as point #1.
#3 The locale files go in locale/English/user_fields (or whichever language you use).
#4 The 2 include files go in includes/user_fields.

Once you have completed all of the above you should be able to see and enable your new field under Admin => User Fields.

Any questions, please reply to this thread.
Edited by Falk on 11-09-2008 22:24,
0 replies

39 posts

S
shearer
S
  • Member, joined since
  • Contributed 199 posts on the community forums.
  • Started 45 threads in the forums
answered
Member

Hi Digi

can you tell, how i can make this work, with a must fill out field. before a user can sign up.
0 replies
W
WEC
W
WEC 10
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 5 threads in the forums
answered
Veteran Member

Check how the Email Address field is handled.
0 replies
J
Josso
J
Josso 10
–––
Without faith, nothing is possible. With it, nothing is impossible
  • Senior Member, joined since
  • Contributed 309 posts on the community forums.
  • Started 1 thread in the forums
answered
Senior Member

Ain't it hardcoded?
0 replies
S
shearer
S
  • Member, joined since
  • Contributed 199 posts on the community forums.
  • Started 45 threads in the forums
answered
Member

yep. it is.
0 replies
M
Martijn78
M
euhh...
  • Member, joined since
  • Contributed 107 posts on the community forums.
  • Started 25 threads in the forums
answered
Member

Just made my first extra field "adres"!
Not very important, but it was really simple following your steps Digi! :D


I made a little package of it and I wanted to attach so we can use each others user fields but I now see I can't attach B)

Is'nt that a good idea? Make this post into a uge profile-fields database?
0 replies
P
phil
P
phil 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
answered
Junior Member

Yeah that was perfect, just what I needed. Thanks a lot :)
0 replies
K
kisses
K
kisses 10
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 6 threads in the forums
answered
Junior Member

Would it be possible to make fields required? Also, is it possible to add user field groups?

I am loving the new version 7! It's awesome... great job...
0 replies
M
Martijn78
M
euhh...
  • Member, joined since
  • Contributed 107 posts on the community forums.
  • Started 25 threads in the forums
answered
Member

Quote

WEC wrote:
Check how the Email Address field is handled.


So this question was allready answered...
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Started this discussions
  • Answered 11 questions
answered
Super Admin

Atm it isn't possible but i can alter it so it can be done, should be in the next rc or final, ok?
0 replies
D
draganon
D
  • Newbie, joined since
  • Contributed 8 posts on the community forums.
  • Started 2 threads in the forums
answered
Newbie

TY Digi, I am interested in that aswell. Question, how can we add the user fields on the registration page? And how can we add userfields on custom pages?
Edited by draganon on 23-06-2008 00:22,
0 replies
S
shearer
S
  • Member, joined since
  • Contributed 199 posts on the community forums.
  • Started 45 threads in the forums
answered
Member

Quote

Digitanium wrote:
Atm it isn't possible but i can alter it so it can be done, should be in the next rc or final, ok?


Yep perfect. becores it is a good thing. against spam bots.
0 replies
D
Daywalker
D
"Might and Greed will never outweigh Honor and Loyalty"

Come join us for IRC Support: Here
  • Member, joined since
  • Contributed 152 posts on the community forums.
  • Started 31 threads in the forums
answered
Member

Digi, the only thing that I could see this becoming better is an option for Admin added things and User added things.

Some items an Admin only can add, or whoever has access to the members list, and some items that the user can add themselves.
0 replies
N
Ninos
N
Ninos 10
  • Member, joined since
  • Contributed 58 posts on the community forums.
  • Started 11 threads in the forums
answered
Member

great guide!

Now just wondering how I'd create a group to put them i, rather than be under an exxisting one?
Oh and how to make the fields apear on profile view?
Edited by Ninos on 25-06-2008 08:52,
0 replies
H
HobbyMan
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
answered
Veteran Member

Excellent, this is exactly what I needed for one of my sites. :D

Kudos, Sir Digi
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Started this discussions
  • Answered 11 questions
answered
Super Admin

I've reviewed the coding and it will require a bit of extra work, while its too late for v7.00 i will be happy to release a mod shortly after final. most likely it will be part of v7.01. So i've not forgotten and it is on my dev list.
0 replies
A
Arda
A
Arda 10
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 11 threads in the forums
answered
Member

and how about improving this baby like extended profile which muscapaul is updating very lately?

which admins should add fields via admin panel which can be shown from profile, edit profile etcetc..

edit: i didn't know that extended profile is already ported to v7! check www.muscapaul.com to get the mod for v7, Thanks Paul ;) :)
Edited by Arda on 02-07-2008 20:34,
0 replies
I
icemanpro
I
Those who challenge prefection are the ones who find the flaws in the system.
  • Junior Member, joined since
  • Contributed 26 posts on the community forums.
  • Started 8 threads in the forums
answered
Junior Member

I have one small question about the profile fields. can you have where you can throw raw <div> code into it or does it have to be straight text for the users end?
0 replies
— 2 months later —
M
MT
M
MT 10
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
answered
Newbie

Quote

Martijn78 wrote:
[quote]WEC wrote:
Check how the Email Address field is handled.


Where do i find this Email Adress field?


Thanx
Edited by MT on 22-09-2008 14:17,
0 replies
— 1 month later —
M
MR Sidepart
M
  • Newbie, joined since
  • Contributed 1 post on the community forums.
answered
Newbie

Thank you for this tutorial, I used it to allow people to add their XBOX Live Gamertag into my database, and then have it pop out their gamercard on their profile.

One thing though, I had to go through and manually create a 'user_FIELD' in my fusion_user and fusion_user_field tables. Was this supposed to be done automatically by the code? Perhaps I have an error some where, no one else mentioned having to manually do this. But...well...maybe it's one of those "you should already have known that" things.
0 replies

Category Forum

User Administration - 8

Labels

None yet

Statistics

  • Views 0 views
  • Posts 39 posts
  • Votes 0 votes
  • Topic users 30 members

30 participants

F
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Started this discussions
  • Answered 11 questions
S
S
  • Member, joined since
  • Contributed 199 posts on the community forums.
  • Started 45 threads in the forums
R
R
rqaven 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
D
D
"Might and Greed will never outweigh Honor and Loyalty"

Come join us for IRC Support: Here
  • Member, joined since
  • Contributed 152 posts on the community forums.
  • Started 31 threads in the forums
M
M
euhh...
  • Member, joined since
  • Contributed 107 posts on the community forums.
  • Started 25 threads in the forums
P
P
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
  • Started 3 threads in the forums
W
W
WEC 10
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 5 threads in the forums
P
P
phil 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
I
I
inuken 10
  • Member, joined since
  • Contributed 57 posts on the community forums.
  • Started 14 threads in the forums
S
S
www.postexus.com - Follow Postexus on Facebook.
  • Senior Member, joined since
  • Contributed 359 posts on the community forums.
  • Started 20 threads in the forums
A
A
Arda 10
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 11 threads in the forums
M
M
MT 10
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
J
J
Josso 10
–––
Without faith, nothing is possible. With it, nothing is impossible
  • Senior Member, joined since
  • Contributed 309 posts on the community forums.
  • Started 1 thread in the forums
K
K
kisses 10
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 6 threads in the forums
H
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
J
J
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
  • Started 2 threads in the forums
D
D
  • Newbie, joined since
  • Contributed 8 posts on the community forums.
  • Started 2 threads in the forums
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
I
I
Those who challenge prefection are the ones who find the flaws in the system.
  • Junior Member, joined since
  • Contributed 26 posts on the community forums.
  • Started 8 threads in the forums
N
N
Ninos 10
  • Member, joined since
  • Contributed 58 posts on the community forums.
  • Started 11 threads in the forums
P
P
  • Junior Member, joined since
  • Contributed 21 posts on the community forums.
  • Started 7 threads in the forums
0
0
0biwan 10
  • Junior Member, joined since
  • Contributed 28 posts on the community forums.
  • Started 7 threads in the forums
M
M
  • Newbie, joined since
  • Contributed 1 post on the community forums.
K
K
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
H
H
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
R
R
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 3 threads in the forums
J
J
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
S
S
If it aint broke...Don't fix it!
  • Junior Member, joined since
  • Contributed 37 posts on the community forums.
  • Started 15 threads in the forums
K
K
Kolb 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
V
V
  • Newbie, joined since
  • Contributed 1 post on the community forums.

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet