PDA

View Full Version : Using "display name" instead of username when quoting


fms
02-01-2005, 05:23 AM
Hi,

I'm trying to replace the username with a display name (a custom user profile field) on our forums. I've modified the postbit as recommended. I had some trouble getting the "display name" to appear when a user is quoted in a post but came up with the following modification to newreply.php, which seems to work:


// START QUOTE DISPLAY NAME HACK
// $originalposter = $postinfo['username'];
$originalposter = $postinfo['field5'];
}
else
{
// $getusername = $DB_site->query_first("SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = " . intval($postinfo['userid']));
$getusername = $DB_site->query_first("SELECT field5 FROM " . TABLE_PREFIX . "userfield WHERE userid = " . intval($postinfo['userid']));
// $originalposter = $getusername['username'];
$originalposter = $getusername['field5'];
// END QUOTE DISPLAY NAME HACK


I'm a beginner with vB so could you experts tell me if this is the right way to go about this?

If anyone can help with getting "display name" to appear in the threadbit and search results, that would be great. :classic:

Edit: Does not change pre-existing quotes, just ones made after this change.

The following modification to functions/functions_newpost.php appears to work (again, it's not retroactive, works for posts made after the change):


// START QUOTE DISPLAY NAME HACK
// $post['postusername'] = $bbuserinfo['username'];
$post['postusername'] = $bbuserinfo['field5'];
// END QUOTE DISPLAY NAME HACK


It stores the "display name" instead of the username in the thread table (I've got the "display name" custom profile field restricted to alphabetic characters, underscores and spaces).

I'm just a beginner at this so if it's a bad idea maybe a smarter person than me can advise.