On the hook
fetch_musername, you could use something like:
PHP Code:
if (is_member_of($user, $special_group))
{
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';
}
If you had a special User Field that you created (Admin CP -> User Profile Fields -> Add User Profile Field), you could use that value for the colour like so:
PHP Code:
if (is_member_of($user, $special_group))
{
$my_special_color = $user['fieldXX'];
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';
}
In some areas there
fetch_musername() is called, it doesn't send the UserFields along with the UserInfo. So you might want to check to make sure the field exists on the array, first.
PHP Code:
if (is_member_of($user, $special_group))
{
if (!array_key_exists('fieldXX', $user)) {$user = fetch_userinfo($user['userid']);}
$my_special_color = $user['fieldXX'];
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';
}
(Note that if a User's Info is already in the userinfo cache, it will just fetch what's in the cache, but you
probably won't run into that problem. If you do, that can be gotten around with an extra line or two of code, to unset that User's $usercache entry. Just post back if you have problems.)
You can specify a Default colour, in case one is not yet set for the user.
PHP Code:
if (is_member_of($user, $special_group))
{
if (!array_key_exists('fieldXX', $user)) {$user = fetch_userinfo($user['userid']);}
$my_special_color = ($user['fieldXX']) ? $user['fieldXX'] : $my_default_color;
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';
}
Note, of course, that you will have to change
fieldXX to whatever your field is, and set a value for
$special_group. I do recommend that you use a User Profile Field, too, although you CAN make an extra field right on the user table. (That's actually what I did myself before I found out about user Profile Fields and felt dumb for doing so, heh.)
Post back if you have any questions or run into any problems.
--------------- Added [DATE]1308244982[/DATE] at [TIME]1308244982[/TIME] ---------------
Oh, as for that marquee, I have something similar, but it was a rainbow text I programmed for my members who want to act all gay.
Use the
fetch_musername hook again, and this code:
PHP Code:
$len = 16;
$base='123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$max=strlen($base)-1;
$randstr='';
mt_srand((double)microtime()*1000000);
while (strlen($randstr)<$len+1) {$randstr .= $base[mt_rand(0,$max)];}
$user['musername'] = '
<span id="spastic_username_container_'.$randstr.'">' . $user['username'] . '</span>
<script type="text/javascript">
set_as_spastic(document.getElementById(\'spastic_username_container_'.$randstr.'\'),\''.$user['username'].'\');
</script>';
That Random String bit is important because each place a name occurs has to have a random ID. Don't worry, though--it doesn't take a lot of processing power, even though it looks kind of complicated. XD
ALSO, you must enter the following javaScript into your
headinclude template:
HTML Code:
<script type="text/javascript">
function set_as_spastic(el,name)
{
var randid = 0;
randid = Math.floor(Math.random() * 102400);
//randid = randint(12);
el.id = 'spastic_username_container_' + randid;
spastic_Timer[randid] = 0;
spastic_index[randid] = 0;
spastic_letters[randid] = name.split("");
setInterval("spastic_username("+randid+")", 50);
}
function randint(len)
{
var chars = "0123456789";
if (!len) {len=8;}
var randomstring = '';
for (var i=0; i<len; i++)
{
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
return randomstring;
}
var spastic_Timer = new Array();
var spastic_index = new Array();
var spastic_letters = new Array();
function spastic_username(idstring)
{
var colors = new Array('ff00ff', 'ff0099', 'ff0000', 'ff9900', 'ffff00', '99ff00', '00ff00', '00ff99', '00ffff', '0099ff', '0000ff', '9900ff');
var bgcolors = new Array('880088', '880033', '880000', '883300', '888800', '338800', '008800', '008833', '008888', '003388', '000088', '330088');
spastic_index[idstring]++;
if (spastic_index[idstring] > colors.length-1) {spastic_index[idstring] = 0;}
var temp_index = spastic_index[idstring];
var output = '';
for (var i=0; i<spastic_letters[idstring].length; i++)
{
if (temp_index > colors.length-1) {temp_index = 0;}
output += '<span style="color:#'+colors[temp_index]+'; background-color:#'+bgcolors[temp_index]+';">' + spastic_letters[idstring][i] + '</span>';
temp_index++;
}
document.getElementById('spastic_username_container_'+idstring).innerHTML = output;
}
</script>
Just change the values in the
colors and
bgcolors array in the JavaScript to however you want. The values I have in there now are rainbow-ish, but you can set them however you want. Tinker around with it and see how you like it.
--------------- Added [DATE]1308245060[/DATE] at [TIME]1308245060[/TIME] ---------------
Oh! One more thing... When you put that Script into your headinclude template, you might have to wrap
<vb:literal></vb:literal> tags around it, due to the curly braces.