They also have ability to edit the field in the admin section as requested somewhere.
The field is NOT compulsary when registering. But could be easily altered so that it is.
The field is viewable by everyone. It is easy to change it so only admins can view it if you wish.
I have used my real name mod as a basis so in this example the new field is for a real name.
Simply replace every instance of realname with whatever you want to call the field!
Here goes:
First you need to add a new column to your users table ...
Code: Select all
#
#-----[ SQL ]------------------------------------------
#
# If you have a different table prefix then change this command accordingly.
# I have used the default table prefix!
#
ALTER TABLE phpbb_users ADD user_realname VARCHAR (50)
Code: Select all
#
#----- [ OPEN ] -------------------------------------
# This first section modifies registration and profile to input real name
includes/usercp_register.php
#
#----- [ FIND ] -------------------------------------
#
$strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests');
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
'username' => 'username',
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
'realname' => 'realname',
#
#----- [ FIND ] -------------------------------------
#
$sql = "UPDATE " . USERS_TABLE . "
SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . "
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
" . $avatar_sql . "
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
, user_realname = '" . str_replace("\'", "''", $realname) . "'
#
#----- [ FIND ] -------------------------------------
#
$sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
user_allow_pm,
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
user_realname,
#
#----- [ FIND ] -------------------------------------
#
VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popuppm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
$user_style, 0, 1,
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
'$realname',
#
#----- [ FIND ] -------------------------------------
#
# NOTE There are 2 instances of this add it for both!
$username = stripslashes($username);
#
#----- [ AFTER, ADD ] -------------------------------------
#
$realname = stripslashes($realname);
#
#----- [ FIND ] -------------------------------------
#
else if ( $mode == 'editprofile' && !isset($HTTP_POST_VARS['avatargallery']) && !isset($HTTP_POST_VARS['submitavatar']) && !isset($H
TTP_POST_VARS['cancelavatar']) )
{
$user_id = $userdata['user_id'];
$username = $userdata['username'];
#
#----- [ AFTER, ADD ] -------------------------------------
#
$realname = $userdata['user_realname'];
#
#----- [ FIND ] -------------------------------------
#
display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, &$new_password, &$cur_password, $password_confirm, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popuppm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies, $allowviewonline, $user_style, $user_lang, $user_timezone, $user_dateformat, $userdata['session_id']);
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
$userdata['session_id']
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
, $realname
#
#----- [ FIND ] -------------------------------------
#
$template->assign_vars(array(
'USERNAME' => $username,
#
#----- [ AFTER, ADD ] -------------------------------------
#
'REALNAME' => $realname,
#
#----- [ FIND ] ----------------------------
#
'L_EMAIL_ADDRESS' => $lang['Email_address'],
#
#----- [ AFTER, ADD ] -------------------------------------
#
'L_REALNAME' => $lang['real_name'],
'L_REALNAME_VIEWABLE' => $lang['real_name_viewable'],
#
#----- [ OPEN ] -------------------------------------
#
includes/usercp_avatar.php
#
#----- [ FIND ] -------------------------------------
#
function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat, &$session_id)
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
&$session_id
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
, &$realname
#
#----- [ FIND ] -------------------------------------
#
$params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat');
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
'dateformat'
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
, 'realname'
#
#-----[ OPEN ]------------------------------------------
# This section puts the entry field for a real name into registering
# and into editing pofile.
# Remember to do this for every template you support
#
templates/subSilver/profile_add_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1" width="38%"><span class="gen">{L_USERNAME}: *</span></td>
<td class="row2"><input type="text" class="post" style="width:200px" name="username" size="25" maxlength="40" value="{USERNAME}" /></td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1"><span class="gen">{L_REALNAME}: </span></td>
<td class="row2">
<input type="text" class="post"style="width: 200px" name="realname" size="25" maxlength="50" value="{REALNAME}" />
</td>
</tr>
Code: Select all
</tr>
Now you need to be able to let people view the new field. So let's put it into viewing the users profile. Currently it's below the username but can be moved using knowledge of basic html ...
Code: Select all
#
#-----[ OPEN ]------------------------------------------
#
#
includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------
#
'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : '&',
#
#-----[ AFTER, ADD ]------------------------------------------
#
'REALNAME' => ( $realname ) ? $realname : '&',
#
#-----[ FIND ]------------------------------------------
#
//
// Generate page
//
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$realname = $profiledata['user_realname'];
#
#-----[ FIND ]------------------------------------------
#
'L_INTERESTS' => $lang['Interests'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_REALNAME' => $lang['real_name'],
#
#-----[ OPEN ]------------------------------------------
#
# Remember to do this for every template you support
#
templates/subSilver/profile_view_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_JOINED}:&</span></td>
#
#-----[ BEFORE ADD ]----------------------------------------
#
<tr>
<td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_REALNAME}:&</span></td>
<td><b><span class="gen">{REALNAME}</span></b></td>
</tr>
Here it is a real name field. You'll need to change the Real Name tag with somthing else!
Code: Select all
#
#-----[ OPEN ]------------------------------------------
#
# Remember to do this for every language you support
# It needs translating!!!
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// Errors (not related to a
// specific failure on a page)
//
$lang['Information'] = 'Information';
$lang['Critical_Information'] = 'Critical Information';
#
#-----[ BEFORE, ADD ]------------------------------------------
#
//
// Language variables for the New field Mod
//
$lang['real_name'] = 'Real Name';
Once again this is put below the username. To move it it's simple HTML.
Code: Select all
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_users.php
#
#-----[ FIND ]------------------------------------------
#
$username = ( !empty($HTTP_POST_VARS['username']) ) ? trim(strip_tags( $HTTP_POST_VARS['username'] ) ) : '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$realname = ( !empty($HTTP_POST_VARS['realname']) ) ? trim(strip_tags( $HTTP_POST_VARS['realname'] ) ) : '';
#
#-----[ FIND ]------------------------------------------
#
$username = stripslashes($username);
#
#-----[ AFTER, ADD ]------------------------------------------
#
$realname = stripslashes($realname);
#
#-----[ FIND ]------------------------------------------
#
SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", $aim) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_sig_bbcode_uid = '$signature_bbcode_uid', user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowavatar = $user_allowavatar, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_allow_pm = $user_allowpm, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_active = $user_status, user_rank = $user_rank" . $avatar_sql . "
#
#-----[ IN-LINE, FIND ]------------------------------------------
#
. $avatar_sql . "
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, user_realname = '" . str_replace("\'", "''", $realname) . "'
#
#-----[ FIND ]------------------------------------------
#
$username = htmlspecialchars(stripslashes($username));
#
#-----[ AFTER, ADD ]------------------------------------------
#
$realname = htmlspecialchars(stripslashes($realname));
#
#-----[ FIND ]------------------------------------------
#
$username = htmlspecialchars($this_userdata['username']);
#
#-----[ AFTER, ADD ]------------------------------------------
#
$realname = htmlspecialchars($this_userdata['user_realname']);
#
#-----[ FIND ]------------------------------------------
#
$s_hidden_fields .= '<input type="hidden" name="username" value="' . str_replace("\"", "&", $username) . '" />';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$s_hidden_fields .= '<input type="hidden" name="realname" value="' . str_replace("\"", "&", $realname) . '" />';
#
#-----[ FIND ]------------------------------------------
#
'USERNAME' => $username,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'REALNAME' => $realname,
#
#-----[ FIND ]------------------------------------------
#
'L_USERNAME' => $lang['Username'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_REALNAME' => $lang['real_name'],
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/user_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1" width="38%"><span class="gen">{L_USERNAME}: *</span></td>
<td class="row2">
<input class="post" type="text" name="username" size="35" maxlength="40" value="{USERNAME}" />
</td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1" width="38%"><span class="gen">{L_REALNAME}: *</span></td>
<td class="row2">
<input class="post" type="text" name="realname" size="35" maxlength="40" value="{REALNAME}" />
</td>
</tr>
It is possible to do the following:
- View the new field in memberlist, viewtopic, usergroups etc.
- Make the new field required when registering.
- Make it so that a user cannot change the field when editing profile.
- Make the new field only viewable by admins (as in the real name mod).