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.
Not a member yet? Click here to register.
Forgot Password?

Colored names with certain ranks

Asked Modified Viewed 720 times
J
jordyveldos
J
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

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 PHPFusion 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

 
Edited by jordyveldos on 23-10-2020 16:44,
0 replies

2 posts

F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

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.
 
Edited by Falk on 24-10-2020 01:24,
1 reply
J
jordyveldos
J
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

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
Edited by jordyveldos on 24-10-2020 14:22,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 2 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

F
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
J
J
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet