Hello,
I'm using a mod that applies users to a secondary member group if they donate. I would like the ability to show the member group color if they don't have a primary member group color set.
I have dug around the Display.php in Sources, and around line 424 there is this code.
if (!empty($row['online_color']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
Is it possible to add an additional check if there is a secondary member group color if no primary member group is selected?
Thanks for the time. ;)
The problem is that the secondary membergroups information isn't retrieved there. So you need to get that from the database...
There are already mods that do get the secondary membergroups but I'm not sure if they get the group color
I was abled to edit the sql statment to this,
$request = $smcFunc['db_query']('', '
SELECT
lo.id_member, lo.log_time, lo.id_spider, mem.real_name, mem.member_name, mem.show_online,
mg.online_color, mg.id_group, mg.group_name, mem.additional_groups
FROM {db_prefix}log_online AS lo
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lo.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_mem_group} && mem.additional_groups = "" THEN mem.id_post_group WHEN mem.id_group = {int:reg_mem_group} && mem.additional_groups = 18 THEN mem.additional_groups ELSE mem.id_group END)',
array(
'reg_mem_group' => 0,
)
);
Where 18 is the secondary group that i want to check on, i'm sure there a better way to do this than just hard coding the 18 of the group... maybe someone else knows how.
This will only show the secondary member color, if the primary member group is a normal user and has 18 as the secondary group else it uses the primary group color.
Hi utroda,
Was there anything else that needed to be changed? I'm trying to do this in my forum as well (I have more than one membergroup I want to check for colours, but figured I could just expand the logic in the SQL).
I've tried using your code and changed the ID from 18 to 12 (the membergroup I'm testing this on) but the user names are not displaying with the membergroup colour.
Was it just the SQL you modified?
Thanks in advance for any advice you can provide :)
You can use something like this (lame self-advertising :P )
http://custom.simplemachines.org/mods/index.php?mod=3805
It allows you to show additional membergroups but also gets each one's color. With some extra logic you can choose which color to use ;)
Thanks margarett. I'll install that and have a play around with the code.