Search    
| | | | |

Previous Blogs
 
Search:


VXT News
:: Star Trek Movie & Series Rankings [Updated]
:: Half Life 2 - Episode 2 - Portal Acheivements
:: VXT Fortran
:: The Ovation VXT Guitar
:: My Rants

» More 

Computer Tips & Reviews
:: Computer News Feeds
:: Opera: The Steve Fonyo of Browsers
:: Web Development Tip: Breaking Out Of Frames
:: phpBB3 Version 3.0.5 Email Error
:: Internet Explorer 8: To Install Or Not To Install
:: Computer Tips: How to Take Screenshots

» More 

Transformers News
:: My Transformers Collection
:: Transformers Reviews: ROTF Human Alliance Bumblebee
:: Top 10 G1 Transformers Episodes
:: Transformers: Revenge of the Fallen Review
:: Transformers Reviews: Revenge of the Fallen Optimus Prime
:: TFcon 2009

» More 

Personal
:: Peter & Lily's Wedding
:: The Ovation VXT Guitar
:: Old Picture
:: SYTYCD Tour 2006, Toronto
:: My Sister Annie's Daughter Natalie

» More 


Popular Blogs
PHPBB3 Tips: How To Query Custom Profile Fields
Comment from Seebz on Jun 10, 2010, 9:21:04 AM
Lost Finale - A Big Disappointment
Comment from vxt on May 24, 2010, 10:16:20 PM
Configuring Speedstream 6520 For Modem Only Mode
Comment from vxt on May 12, 2010, 3:50:26 PM
Transformers Reviews: Revenge of the Fallen Optimus Prime
Comment from Arry Constantine Prime on Mar 22, 2010, 10:15:18 PM
Filezilla vs WinSCP
Comment from vxt on Dec 18, 2009, 3:21:57 PM

Links
SYTYCD Fans
SYTYCD Canada Season 3 Ep11 - The Top 18 Perform
Who Pissed In Your Corn Flakes
How to Park at Pacific Mall (or any Asian Mall)
Simon - Space Piracy!
Oh, snap!
Simon Carr
My Friend's Band - Octoberman
Toronto Weather
Nam Tran Makeup


Ads

Sites I've Worked On
Oakville Optometry
Astro Amusements
Calexis Advertising & Marketing Counsel
CWDMA
Canada Bread Foodservice
Star Electronics
Wizard World
Screemers
Half Wasted


Viet's Online Games
Web based games that I've created. Enjoy!




Did You Know?

PHPBB3 Tips: How To Query Custom Profile Fields
November 17, 2009

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.

Adding Fields Within PHPBB3 Pages


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, styles\{ YOUR TEMPLATE }\template and edit the viewtopic_body.html file. Add the code below in the appropriate area.
{postrow.PROFILE_GENDER_NAME}: {postrow.PROFILE_GENDER_VALUE}

GENDER is the name that you gave the field in the adminstrative control panel.

Adding Fields In Custom Pages


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]];
          }
     }
}
Bookmark and Share
Comments

Total Comments: 1
Posted by: Seebz on June 10, 2010 9:21:04 AM ETPost link
Website
thank you for the tip
Valid XHTML 1.0!
© Copyright 2010 Viet Tran. All Rights Reserved. Powered by Content ManagerTM | Site Map | Top