TinyPortal

Development => Block Codes => Topic started by: feeble on May 17, 2006, 05:55:07 AM

Title: Combining Custom Profile Field with Profile
Post by: feeble on May 17, 2006, 05:55:07 AM
Test Code to show how to combine unknown's Custom Profilefield with users profile
To add these custom profile fields i used a modified - Xfire mod (http://mods.simplemachines.org/index.php?mod=174)

If you need help with what you need this for, please feel free to ask.

Since the data in the Custom Profilefield is stored in the theme table, we need to combine the data into one array for use. This is just one possible solution

Quick Demo: two custom profiles (xfire and bf2pid) linked upto the correct profile.
http://www.nsxhq.com/index.php?page=37 (http://www.nsxhq.com/index.php?page=37)

Note: So that only users from membergroup 11 in the table
if(preg_match('/11/i', $row['additionalGroups']))

if you need anyhelp at all with incorporating this into your site please feel free to ask.
Code: Copy and Paste straight into an article - Make sure you edit out preg_match line, and change the details to your correct custom profilefields

global $db_prefix, $scripturl;

$request = db_query("
SELECT ID_MEMBER, realName, posts, additionalGroups
FROM ".$db_prefix."members", __FILE__, __LINE__);
$return = array();
$counter = 0;
$ifxfire = "";
$ifbf2pid = "";
while ($row = mysql_fetch_assoc($request))
{
if(preg_match('/11/i', $row['additionalGroups']))
{
$request_member = db_query("
SELECT ID_MEMBER, variable, value
FROM {$db_prefix}themes
WHERE  ID_MEMBER='".$row['ID_MEMBER']."'", __FILE__, __LINE__);
while ($row_member = mysql_fetch_assoc($request_member))
{
if($row_member['variable'] == "Xfire")
$ifxfire = $row_member['value'];
if($row_member['variable'] == "bf2pid")
$ifbf2pid = $row_member['value'];
}
$return[$counter] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realName'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>',
'bf2pid' => $ifbf2pid,
'xfire' => $ifxfire);
$ifxfire = "";
$ifbf2pid = "";
$counter++;
}
}

mysql_free_result($request);

$temp_array = array();
foreach ($return as $member)
{
$temp_array[] = "<tr><td>".$member['link']."</td><td>".$member['xfire']."</td><td>".$member['bf2pid']."</td></tr>";
}

echo "<table  width='95%' align='center'><thead><tr>
<th >Name (".$counter.")</th>
<th >Xfire</th>
<th >BF2 Pid</th>
</tr></thead><tbody>";
echo implode('', $temp_array);
echo "</tbody></table>";


Example Use: BF2 Leaderboard
http://www.nsxhq.com/index.php?page=33 (http://www.nsxhq.com/index.php?page=33)
Using the above method this leaderboard:
-Only adds members in the clan to the leaderboard
-If user is on the leaderboard - then highlight that user
Title: Re: Combining Custom Profile Field with Profile
Post by: animecosmo on February 08, 2007, 08:37:08 AM
Again, I know this is old, but I'm new to TP so am reading all the old snippets. I'm confused as to what exactly this does. Could someone please explain?
Title: Re: Combining Custom Profile Field with Profile
Post by: feeble on February 08, 2007, 07:12:08 PM
lol wow this is really old, dont even think i use this any more

basically, some mods store user data in the theme table. this just got the data and matched it correctly with the forum user