This blog includes code on how to add custom profile fields to the side profile as well as how to retrieve custom profile fields from outside of the PHPBB pages if you are integrating PHPBB3 with your site.
In the administrative control panel, you need to add the custom field. Go to USERS & GROUPS, then click on the Custom profile fields link on the left side bar. Click on the, "Create new field" button. Fill out the form.
If you want to add a gender field to the side profile, for example, go to this folder,
file. Add the code below in the appropriate area.
GENDER is the name that you gave the field in the adminstrative control panel.
If you are integrating your site with PHPBB3 and want to get the custom profile fields outside of the PHPBB3 pages, this is the code you need to use.
# Include this code to use the user class from PHPBB.
define('IN_PHPBB', true);
$phpbb_root_path = {PATH TO YOUR FORUM};
$phpEx = "php";
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
//These are the ones that handle sessions.
$user->session_begin();
$auth->acl($user->data);
# Get the custom field names
$db = mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
mysql_select_db(DB_NAME);
$query = "SELECT * FROM `phpbb_profile_fields`";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$rowCustomFields[] = $row;
}
# Get custom field data
$query = "SELECT * FROM `phpbb_profile_fields_data`
WHERE `phpbb_profile_fields_data`.user_id=".$user->data[user_id];
$result = mysql_query($query);
$rowCustomFieldsData = mysql_fetch_array($result);
if (is_array($rowCustomFields)) {
foreach($rowCustomFields AS $k => $v) {
# I only check for one type but there are possibly more field types that
# you should check for. I believe field_type=5 is a select dropdown
if ($rowCustomFields[$k][field_type] == 5) {
# For field_type=5, get the values for them since they are stored
# only as IDs in the fields_data table
$query = "SELECT `phpbb_profile_fields_lang`.lang_value FROM `phpbb_profile_fields_lang`
WHERE `phpbb_profile_fields_lang`.field_id=".$rowCustomFields[$k][field_id]."
AND (`phpbb_profile_fields_lang`.option_id+1)=".$rowCustomFieldsData['pf_'.$rowCustomFields[$k][field_name]];
$result = mysql_db_query($query);
$thisUserProfile[$rowCustomFields[$k][field_name]] = mysql_result($result,0,0);
} else {
# If it's a text field just assign the value
$thisUserProfile[$rowCustomFields[$k][field_name]] = $rowCustomFieldsData['pf_'.$rowCustomFields[$k][field_name]];
}
}
}