1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Different color username for certain members

Discussion in 'Styling and Customization Questions' started by Divvens, May 24, 2012.

  1. Divvens

    Divvens Well-Known Member

    I want to be able to give different username color to certain members without having them in different groups.

    As in, x member gets pink, x member gets green and x member gets yellow staying in their respective groups without having additional groups to take over styling.

    I offer members a way to change their username colors, and I don't want to have different usergroup with different styling rules.

    This would be easy if xf by default offered images to be added in user title's (trophy), but we force user titles via groups and we can't override one group 100% or else the rank tags we have arranged breaks.

    So, is there anyway I can give a certain user different username color? By styling rules or special user permissions?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The username markup goes by usergroups only. You would have to modify the code to make an exception for specific users:

    CapnLuffy likes this.
  3. MagnusB

    MagnusB Well-Known Member

    You can do it with template edits, depending on how you want it configured. One is to create a custom field and use that to set the color of the username using style="...." or you can use the username as a class, then you can do this with extra.css.
    CapnLuffy likes this.
  4. Divvens

    Divvens Well-Known Member

    Can that be done for a certain user only? Or would that apply to all, the custom field option sounds good would you tell me how that would be done?
  5. MagnusB

    MagnusB Well-Known Member

    In template message_user_info, find:
            <h3 class="userText">
                <xen:username user="$user" itemprop="name" rich="true" />
                <xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user}</xen:contentcheck></em></xen:if>
                <!-- slot: message_user_info_text -->
    The username is generated with the second line, I just tested on my site and adding style="color:red;" etc work, but I am not sure if using custom user fields will. You can try (meaning I have not tested this) by changin it too:
              <xen:username user="$user" itemprop="name" rich="true" style="color: {$message.customFields.field_id}" />
    You have to change field_id to the field you want to use. You should force people to use web colors, though.
    Jake Bunce and CapnLuffy like this.
  6. Freeze

    Freeze Member

    <xen:username user="$user" itemprop="name" rich="true" style="color: {$message.customFields.field_id}" />
    What would be the right syntax if I wanted the default username (usergroup) color to show UNLESS a unique is specified in the custom field? Or does it work that way with this?
    Edit: The edit works, but it doesn't visually show!


    If you go over the username and check the properties with chrome/firefox, it clearly shows an the new color which the username should use but it still shows the old username color.
    Jake Bunce likes this.
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes that will work.

    What template are you editing?
  8. Freeze

    Freeze Member

    I've added the following code on message_user_info
    <xen:username user="$user" itemprop="name" rich="true" style="color: {$message.customFields.usernameColor} !important" />
    But as you can see on this post - http://orojackson.com/threads/good-morning-world-one-post-per-day.43/page-128#post-38837 if you check the properties on the username "kurumu-chan", it shows the new color in the attributes but doesn't change the actual username color (from orange to white) [please select the default theme if by chance you have another theme on there, its supposed to be a red-ish theme]

    I'll attach two images to explain what I'm talking about :)
    nocolorchange.png styleattribute.png
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    In that template you need to use {$user.customFields.usernameColor} instead of {$message.customFields.usernameColor}.
  10. Freeze

    Freeze Member

    Thank you Jake :)

    But even after changing it to {$user.customFields.usernameColor}, it's the same. Even though there is an !important rule for some reason it doesn't override it.
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    <a href="members/kurumu-chan.451/" class="username" itemprop="name" style="color: #ffffff !important;"><span class="style12">kurumu-chan</span></a>
    You've got usergroup markup in there. That creates an inner span with a style class that may override the other inline styling.

    Edit your groups and remove any username CSS.
    Freeze likes this.
  12. Freeze

    Freeze Member

    Ah thanks for pointing that out.

Share This Page