Jump to content
MakeWebGames

Recommended Posts

Posted

Hi, i have tried a lot of thigns and cannot get it to work, i dont really want to have to put an if function for usernames in all the files that displays them so im looking for a function to go into globals.php

This should give users a bold yellow name if they are a donator, red name if they are admin, green if a secretary and a purple for an assistant, if anyone can post anything up here that i can try ill much appreciate it :) THANKS :)

Posted
  function username($user_level,$username) {
	$staff_colours = array(
0 => '#000', 
1 => '#fff', 
2 => '#CC0', 
3 => '#FFC', 
5 => '#006'
	);
	$return_data = (array_key_exists($user_level, $staff_colours)) ? '<span style="color: '.$staff_colours[$user_level].';">'.$username.'</span>' : $username ;
return $return_data;
 }
  echo username($ir['user_level'],$ir['username']);

Quoted from (Internal Link)

Next time use the Search Function

MWG-search.jpg

Also just incase basically that code would go below your fetch row of $ir and then simple put

$ir['username'] = username($ir['level'],$ir['username']);

(not the best idea though when you call some queries like WHERE username = "'.$ir['username'].'")

Posted

EDIT: Didnt see cims post, use that; much better and easier :)

For crims, you have to edit every page For this, you dont;

In header.php:

Find $u=$ir['username'];

Below add this and change for others ( for colours ):

if($ir['user_level'] == 2) {
$u = '<span style="color: red;">'. $ir['username'] .'</span>';
$ir['username'] = $u;
}
Posted

Comment about CrimGame's version. Use the global function, then just edit every page you display the username using the function. That would eliminate the username=$ir['.... problem, and it would give you a bit more control over where you can staff color.. where you can't. It may be a pain in the ass, but, taking an hour at top to add something worthwhile is necessary sometimes.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...