Re: Admin - how to get the groups for a user?

Lukas Kahwe Smith <[email protected]> Mon, 05 Dec 2005 22:13:43 +0100
Newsgroups gmane.comp.php.pear.liveuser
Message-ID <[email protected]>
Stacy Johnson wrote:
> Hi, I'm using the Perm_Medium admin class and trying to use getGroups to 
> come up with the groups for a user, but I'm a little stumped.
> 
> I am basically trying to create an "Edit user" type page for admins, and 
> I want to let them choose which group the user belongs to.  I need to 
> show which group the user currently belongs to, which is what I am 
> having trouble with.    Here is what I am looking at:
> 
>                               // Get group names/ids from DB for dropdown
>                               $groups = $admin->perm->getGroups();
> 
>                              // Get the group that this user belongs to  
> (doesn't work)
>                               $filters = array(
>                                               'perm_user_id' => $id
>                               );
>                                $usergroup = 
> $admin->perm->getGroups($filters);

you are almost there :-)

$params = array(
     'filters' => array(
         'perm_user_id' => $id
     )
);
$usersGroup = $admin->perm->getGroups($params);

regards,
Lukas