MyBB Community Forums

Full Version: Usergroup variable in thread list?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

Been absolutely loving working with MyBB, ran into a bit of a roadblock that I'd love some input on from the community!

So, I'm attempting to make threads started by a particular usergroup highlighted in the thread list for forums, for example let's say I have a usergroup "Pro", all threads started by Pro users should have a background color that I define via CSS in the main threads listing. 

I've already worked out how to do this with posts (using a {$usergroup['gid]} variable on the div's class) however that variable doesn't appear to be allowed in the forumdisplay_threads template, and I can't seem to find a variable that is allowed for that template.

I'm not entirely sure if I should go the "allow php execution in templates" route, or hard-code a variable that retrieves a thread author's usergroup and is allowed in the threads template. (Or?) perhaps change the $usergroup conditional to allow use in the thread template (I'm not entirely sure where the definitions are located).

Any input would be appreciated!
Variables are not "allowed" - that's not how programming works. They are defined in source files and you always need to check whether there's an available variable that contains the information you need. In this case there is none - the query doesn't even select usergroup: https://github.com/mybb/mybb/blob/featur...y.php#L858
SELECT t.*, {$ratingadd}t.username AS threadusername, u.username
You need to change it to:
SELECT t.*, {$ratingadd}t.username AS threadusername, u.username, u.usergroup
and then you can use {$thread['usergroup']}