Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Colored names with certain ranks

Hello,

I want to make a colored name in for example, the online users panel and forums for people that have a certain rank or are in a usergroup.

for instance; I am super admin on my website, so I want my name to be in red and a friend of mine is a Moderator and I want his name to be blue and I have a custom usergroup with a donators rank and want the usernames in that group to be purple.

Is that possible?

The only post I could find is a very old post and was for PHP-Fusion v6.0. I still tried to follow up the tutorial, but it didn't work.
https://www.php-fusion.co.uk/infusions/forum/viewthread.php?thread_id=14089


I hope someone can help me,
Thanks.

-Jordy

 
See one of the latest posts, https://www.php-fusion.co.uk/infusions/forum/viewthread.php?thread_id=14089&rowstart=20#post_83488 , should work.
 
Thank you for your post, I did try that, but I'll give it another shot. Maybe I did something wrong, thank you anyways smile
Check your errorlog if there are any notices that can give a hint where it fails, might need to read in $username variable. At somepoint we used superglobals. But it has been disabled.
 
Alright,

So I got it to work, for everyone else that finds this thread and is interested in how I did it:

You'll need to make a new Column in your MySQL database -> fusionXXXXXX_users called "user_color" without quotes.

Insert this code in your maincore.php:

Quote

// Colorize the given username
function colorize_user($user_name)
{
$result = dbquery("SELECT user_color FROM ".DB_PREFIX."users WHERE user_name='$user_name'" );
if (dbrows($result) != 0)
{
$data = dbarray($result);
$color = ( $data['user_color'] != '' ) ? "<span style='color:".$data['user_color']."'>$user_name</span>" : $user_name;

return $color;
}
}


search in your maincore.php for:

Quote

// User profile link
function profile_link($user_id, $user_name, $user_status, $class = "profile-link") {
    global $locale, $settings;

    $class = ($class ? " class='$class'" : "");

    if ((in_array($user_status, [0, 3, 7]) || checkrights("M")) && (iMEMBER || $settings['hide_userprofiles'] == "0")) {
        $link = "<a href='".BASEDIR."profile.php?lookup=".$user_id."'".$class.">".$user_name."</a>";
    } else if ($user_status == "5" || $user_status == "6") {
        $link = $locale['user_anonymous'];
    } else {
        $link = $user_name;
    }

    return $link;
}



and change it to:

Quote

// User profile link
function profile_link($user_id, $user_name, $user_status, $class = "profile-link") {
    global $locale, $settings;

    $class = ($class ? " class='$class'" : "");

    if ((in_array($user_status, [0, 3, 7]) || checkrights("M")) && (iMEMBER || $settings['hide_userprofiles'] == "0")) {
        $link = "<a href='".BASEDIR."profile.php?lookup=".$user_id."'".$class.">".colorize_user($user_name)."</a>";
    } else if ($user_status == "5" || $user_status == "6") {
        $link = $locale['user_anonymous'];
    } else {
        $link = $user_name;
    }

    return $link;
}

This will change the color of all the profile links to the color you've set in the mysql database (in fusionxxxxx_users -> user_color)

You'll need to change te color for each indivual user yourself, so this is not related to a certain rank.


Hope I could help and @Falk, thank you for your time.

-Jordy
Thread Information
Author
Replies
5 posts
Views
80 times
Last Post
Last updated on 1 month ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Falk, jordyveldos