Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: shockuk on September 23, 2009, 05:15:32 AM

Title: Retrieving User Group ID
Post by: shockuk on September 23, 2009, 05:15:32 AM
Hi all,

Just a quick question -

Currently developing a (my first) mod for SMF. I retrieve the currently logged on user's name using $context['user']['name']

Does anyone know how I would retrieve the ID of which group this user is in?

Thanks very much,
Shockuk.
Title: Re: Retrieving User Group ID
Post by: Arantor on September 23, 2009, 05:16:49 AM
Primary group or secondary groups?
Title: Re: Retrieving User Group ID
Post by: shockuk on September 23, 2009, 05:33:13 AM
Primary :)
Title: Re: Retrieving User Group ID
Post by: Arantor on September 23, 2009, 05:38:55 AM
$context['user']['groups'] should be an array holding them all, $context['user']['groups'][0] should be their primary group.
Title: Re: Retrieving User Group ID
Post by: shockuk on September 23, 2009, 05:59:30 AM
Ah doesn't seem to work matey (there's nothing set in that array).

Maybe I should've mentioned that i'm calling SMF from another script using SSI.php
Title: Re: Retrieving User Group ID
Post by: Arantor on September 23, 2009, 06:01:16 AM
I thought it moved it into $context (which it does in other situations)

$user_info['groups'] instead then.
Title: Re: Retrieving User Group ID
Post by: shockuk on September 23, 2009, 06:08:37 AM
Works like a charm!

Thanks very much :)
Title: Re: Retrieving User Group ID
Post by: Arantor on September 23, 2009, 06:13:35 AM
Good to know that sorted it. I'll mark this one solved for now.