Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function slf_GetUserGroupInfo()
- {
- global $db;
- $Result = array();
- $Fetch = $db->query_read
- (
- 'SELECT '.
- 'usergroupid, '.
- 'usertitle, '.
- 'opentag, '.
- 'closetag '.
- 'FROM usergroup'
- );
- while($Row = $db->fetch_array($Fetch))
- {
- $Result[$Row['usergroupid']]['usertitle'] = $Row['usertitle'];
- $Result[$Row['usergroupid']]['opentag'] = $Row['opentag'];
- $Result[$Row['usergroupid']]['closetag'] = $Row['closetag'];
- }
- return($Result);
- }
- function slf_FormatForumName($ForumId, $UserGroupInfo)
- {
- global $db;
- $Fetch = $db->query_read
- (
- 'SELECT '.
- 'username, '.
- 'IF(displaygroupid=0, usergroupid, displaygroupid) AS usergroup '.
- 'FROM user '.
- 'WHERE userid = '.($ForumId * 1).' '.
- 'LIMIT 1'
- );
- $Row = $db->fetch_array($Fetch);
- // Format name.
- $Group = $Row['usergroup'];
- $OpenTag = $UserGroupInfo[$Group]['opentag'];
- $CloseTag = $UserGroupInfo[$Group]['closetag'];
- return($OpenTag.$Row['username'].$CloseTag);
- }
- ////////////////////////// USAGE ////////////////////////////
- function mysub()
- {
- // First call this at top of the sub
- $UserGroupInfo = slf_GetUserGroupInfo();
- // This is the vBulletin User ID we want to get the name for.
- $TheUserId = 6;
- // Not only get the name, but format it so it looks like a real vBulletin username.
- $ClickableFormattedName = '<a href="/member.php?u='.$TheUserId.'">'.slf_FormatForumName($TheUserId, $UserGroupInfo).'</a>';
- // Do something with it.
- echo $ClickableFormattedName;
- }
Add Comment
Please, Sign In to add comment