Support Forum
Hello,
I'd like to customize my theme so the usernames would show in a different color, based on their user group (mainly for moderators and admins). I'll first apply to that display in the online list that appears at the bottom of each page and maybe later at other places like in each post profile...
I'm seeking recommendations to achieve that:
- will I be able to cleanly implement this without modification to SP core source code ?
- is the user group information easily available so I don't need to do extra queries ?
Thank you.
This functionality is already built into the username display on topic view for each poster. A bunch of special classes are added to each post row so you can specifically style each user based on things like user type, memberships, ranks, etc.
However this is not true of the stats. This will be quite problematic for the stats since the data is not available without more queries. Additionally, the stats are cache so potential for stale data.
If you want to globally do this for every user name displayed, you would want to affect the global display name function. I believe there is a filter on the generation of the html that would allow you to add classes to the display in order to customize the output.
But you would still need to do the additional queries to get the needed data.
Visit Cruise Talk Central and Mr Papa's World
Sorry can't be more specific until Wednesday when back. Think routine something like sp_build_name_display().
If filter, should be easy, although extra query per name, to add a class. If no filter, we can add one.
Visit Cruise Talk Central and Mr Papa's World
I have been checking for different options, including your suggestions.
A good solution I can think of would be to modify (probably hardcoding the username and colors at first) the sp_filter_name_display function in sp-api-filters.php, so the username color display would be consistent everywhere on the forum. Do you see any border effect of doing so ?
Any suggestions on how to do that change without modifying sp-api-filters.php in the core code ?
I see the following code at the end of sp_filter_name_display function
$content = apply_filters('sph_display_name_filter', $content);
but I am not sure on the proper way to handle this in my custom theme code ?
Thank you.
you are not going to be able to do what you want in that filter routine or using the sph_display_name_filter... that only gets the username... you wont be able to add any html or styling because when output it usually will already be within some html tags...
as I said in post #4, I think you want sp_build_name_display() function... Its where we output users names... now I cannot guarantee its all user name displays, but certainly the ones we allow linking to the profile on...
if linking to a profile, the routine it calls will be: sp_attach_user_profile_link()
you will see html generated there where you could add the specific classes you want for color... you might need to do
$user = sp_get_user($userid);
in there to set up a use object... then you can get at that users memberships via $user->memberships
Visit Cruise Talk Central and Mr Papa's World
1 Guest(s)