Advertisement:

Author Topic: Retrieving User Group ID  (Read 2160 times)

Offline shockuk

  • Newbie
  • *
  • Posts: 4
Retrieving User Group ID
« 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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,951
Re: Retrieving User Group ID
« Reply #1 on: September 23, 2009, 05:16:49 AM »
Primary group or secondary groups?

Offline shockuk

  • Newbie
  • *
  • Posts: 4
Re: Retrieving User Group ID
« Reply #2 on: September 23, 2009, 05:33:13 AM »
Primary :)

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,951
Re: Retrieving User Group ID
« Reply #3 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.

Offline shockuk

  • Newbie
  • *
  • Posts: 4
Re: Retrieving User Group ID
« Reply #4 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,951
Re: Retrieving User Group ID
« Reply #5 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.

Offline shockuk

  • Newbie
  • *
  • Posts: 4
Re: Retrieving User Group ID
« Reply #6 on: September 23, 2009, 06:08:37 AM »
Works like a charm!

Thanks very much :)

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,951
Re: Retrieving User Group ID
« Reply #7 on: September 23, 2009, 06:13:35 AM »
Good to know that sorted it. I'll mark this one solved for now.