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

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