VitalEnd Posted July 10, 2010 Posted July 10, 2010 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 :) Quote
Zero-Affect Posted July 10, 2010 Posted July 10, 2010 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 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'].'") Quote
BoGFx Posted July 10, 2010 Posted July 10, 2010 It usually doesn't work if you only edit globals. Quote
Danny696 Posted July 10, 2010 Posted July 10, 2010 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; } Quote
Zero-Affect Posted July 10, 2010 Posted July 10, 2010 Erm no you could do it without editing pages but i explained the issue... Quote
BoGFx Posted July 10, 2010 Posted July 10, 2010 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.