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,251 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

I
inuken
I
inuken 10
  • Member, joined since
  • Contributed 57 posts on the community forums.
  • Started 14 threads in the forums
answered
Member

hello! i made a user field named mood, aftr the example with skype, but i have a problem, when i want to enable it from admin panel - user field, doesnt work. it shows up enable function, i clicked on it, but nothing. and the same goes for o mood field already created. what is the problem? thanks.
0 replies
— 1 month later —
0
0biwan
0
0biwan 10
  • Junior Member, joined since
  • Contributed 28 posts on the community forums.
  • Started 7 threads in the forums
answered
Junior Member

[quote]draganon wrote:
Question, how can we add the user fields on the registration page? /quote]

I'm interested on this too!

I would like to see location and birthdate on my register form!
0 replies
J
jones28s
J
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
  • Started 2 threads in the forums
answered
Newbie

Quote

MR Sidepart wrote:
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?


Hi Digi. I'm having the same problems as Sidepart, but I'm in the middle of a brain lapse at the moment. How do you add the database fields manually? I've done it before through "Custom Pages", but I can't seem to find my notes on how to do this. Any help would be appreciated.

Patrick
0 replies
K
kajkobajk
K
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
answered
Newbie

Hi!
What to do if I already had two new fields in v6.01, I upgraded to v7, and fields dissapeared?

I have them still in database but I don't know how to add them to user "edit profile" and to "user profile" (not in registeration).

In database it's:
favourite_movies (varchar120)
best_movies (text)

Can anyone help? I will be really thankful!
Edited by kajkobajk on 31-01-2009 11:19,
0 replies
— 3 months later —
H
Hamawand
H
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
answered
Newbie

HI I need some help please,,I have problem with my web site,,when people are wants to register in my web the link is going to their email to acctivate thier name in my web is a black coulor and people can not klick on that link because it seems to be an acctive linck
0 replies
R
rqaven
R
rqaven 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
answered
Newbie

Is there a way, so that only the user and, admins can see the content of this user fields?
0 replies
— 5 months later —
J
Jennmc75
J
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
answered
Newbie

I used this example along with the web address field php files to create another web address field. It worked beautifully, except the new field won't show up when you click on the member in the member list. Do I need to modify an additional file in order for the additional web address to show up there?
0 replies
— 4 months later —
R
Ravenheart
R
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 3 threads in the forums
answered
Newbie

Sorry about resurrecting the dead, but we really NEED to be able to add a custom userfield to the registration page to act as a spambot protection. And in my mind this should be added as a default security measure.
0 replies
— 2 months later —
P
Pade2204
P
  • Junior Member, joined since
  • Contributed 21 posts on the community forums.
  • Started 7 threads in the forums
answered
Junior Member

sorry for writing in this old thread.

Can I make this userfield I just added from this guide a field that ONLY the admins can correct, but can be seen by all ?
0 replies
S
starefossen
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
answered
Senior Member

User field only editable for admins but can be viewed by everyone.

PS: See the places I have added && iADMIN

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

if ($profile_method == "input" && iADMIN) {
// 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'] && iADMIN) ? 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'] && iADMIN) ? stripinput(trim($_POST['user_skype'])) : "")."'";
}
?>
0 replies
— 1 month later —
P
pberghs
P
  • Newbie, joined since
  • Contributed 6 posts on the community forums.
  • Started 3 threads in the forums
answered
Newbie

Hey,

there is still no answer about how to make a field required.
i was told to take the code out of the e-mail field, but that is HARD CODED. So, still no answer.
0 replies
— 4 months later —
S
starefossen
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
answered
Senior Member

Will be possible in v7.02.
0 replies
— 2 years later —
K
Kolb
K
Kolb 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
answered
Newbie

Quote

rqaven wrote:

Is there a way, so that only the user and, admins can see the content of this user fields?


I'm sorry to revive such an old thread but this question is the same question I'm trying to find an answer for.

I'm running fusion 7.02.06
0 replies
— 1 year later —
C
Chan
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
answered
Super Admin

Yes you can, Which user field?

Go to /includes/user_fields/ folder, you will see each user field has 2 file. a _include file, and a _var file. You will need to edit the _include one, which File or UF you are trying to mod?
0 replies
— 1 year later —
V
venkatesh
V
  • Newbie, joined since
  • Contributed 1 post on the community forums.
answered
Newbie

i have create the one fields name as location fields.in that i created the two fields in same user_fields.by using the on-change function.in that fields
i keep the two drop down box in the same fields.one box is state of india and other one is an district box.
we selected the any one state in first box.in second box it will be display the district from that specify state only.
That one is prpperly working.while refresh the registration page the state and district is not display.for that i need some code for it plz anyone help me.

Merged on Apr 11 2016 at 13:21:11:
how to add another one fields in same fields
Edited by venkatesh on 11-04-2016 13:21,
0 replies
— 10 months later —
S
SnakeEye
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
answered
Junior Member

It's nice to see how you show people how to create new user fields by creating new files and coding the files themselves. I think it would be better though if the admin system was changed so that the admin could add new user fields through input in the admin panel. Either change the admin panel altogether to have this function or by installing an addon that would add this functionality to the admin panel. This way the admin could add as many user fields they want and give the new user fields any name they want as well. The admin should also have the ability to make new user fields for registration and whether or not they want them to be required fields or not.
0 replies
C
Chan
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
answered
Super Admin

Its in v9 since 2 years ago. Its called Quantum. Embedded in user fields. 9 types of fields.
0 replies
S
SnakeEye
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
answered
Junior Member

Quote

Its in v9 since 2 years ago. Its called Quantum. Embedded in user fields. 9 types of fields.
- by Chan


I am going to have to install v9 as a test bed. I use v7.x now and have very heavily edited a lot of the files including maincore.php and header files and others to get the site to do things I need it to do. I am just dreading having to go back and edit all the v9 files to get the same things I use now. A lot of work. I use scripts for the site to break out of frames if people try to load our site in a frame on their site, a modal script for opening videos with a custom video player, images, flash or any other content I need to open in a modal window using s simple "rel" tag, and a couple others that I hard coded into the files. I also edited index.php so the site opens and displays the news without being redirected to news.php or home.php or something similar. The site simply shows up as www.domain.com instead of www.domain.com/news.php or www.domain.com/home.php. No redirection upon login either except to show index.php When you click the Home link or logo it reverts back to www.domain.com Just not looking forward to having to edit all those files all over again.
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 have seen some sort of addon for it but can´t remember where.
0 replies
C
Chan
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
answered
Super Admin

Quote

Quote

Its in v9 since 2 years ago. Its called Quantum. Embedded in user fields. 9 types of fields.
- by Chan


I am going to have to install v9 as a test bed. I use v7.x now and have very heavily edited a lot of the files including maincore.php and header files and others to get the site to do things I need it to do. I am just dreading having to go back and edit all the v9 files to get the same things I use now. A lot of work. I use scripts for the site to break out of frames if people try to load our site in a frame on their site, a modal script for opening videos with a custom video player, images, flash or any other content I need to open in a modal window using s simple "rel" tag, and a couple others that I hard coded into the files. I also edited index.php so the site opens and displays the news without being redirected to news.php or home.php or something similar. The site simply shows up as www.domain.com instead of www.domain.com/news.php or www.domain.com/home.php. No redirection upon login either except to show index.php When you click the Home link or logo it reverts back to www.domain.com Just not looking forward to having to edit all those files all over again.
- by SnakeEye


Well, these are just a couple of things that need to be done again if you're using PF9. Life is just filled with obstacles you need to overcome.
With many of them things you've pointed out, I think segregation of the site files is possible. You just take them out and place in a custom_file.php and run them whenever you need.

For me, the passion of destroying everything and building up everything again is once a life time opportunity. Literally, once. I have used it to tear away v7 to the bone, and reassemble them piece by piece day by day. I'm even doing it today.

If the site makes money for you, it's going to worth the time and investment. If it doesn't, leave it. There is nothing fancy to break something that has already worked for you. Perhaps, a new site, a new project, then maybe it's alright to change the features and everything. Therefore, I put heavy measures in making upgrade flawless as is to everyone, with this understanding alone.

However, no one should think that with just upgrade script can do it all, it will be able to fix everything for you. No, that's just a start. You need to spend thousands if not hundreds of hours behind tweaking and making things smooth. Hence, the reason of the existing of this support site, and along with all NSS support sites of course, since if someone know how to do them things, they can't communicate or express with understandable language.

I know some of us have grown old, we're not in college anymore and we're about to move on and we're growing tired of pulling through things and swing our magic wand. However, we have been young before, and we have all the kickass stuff still.. it depends on whether you need to or not, but it's not impossible if you really want it done. :)
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