Getting user group ids without any additional queries

Cyb3r

Well-known member
I'm overriding Core function "helperRichUserName" but it seems not all attributes are provided in the $user array, I tried to check "is_staff" and usergroup ids but didn't work, so I tried to create a model for the user by user id:
PHP:
$full_user = XenForo_Model::create('XenForo_Model_User')->getUserById($user['user_id']);

It worked but the queries has doubled, so I was wondering if there's a function that extract only usergroup ids and check it by user_id.
 
Never mind I got it working by checking the display_style_group_id which return the highest level usergroup which was exactly what I need, here is the code for future reference if anyone interested in:
PHP:
if($user['display_style_group_id'] == '13')
{
   // Do something here
}

Change 13 to the usergroup you want to match, if you want more than one group use in_array, here's an example:
PHP:
if (in_array($user['display_style_group_id'], array('13','3')))
{
   // Here goes your code
}


- Cyb3r
 
Top Bottom