API16

JUserHelper/getUserGroups

From Joomla! Documentation

< API16:JUserHelper
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Method to get a list of groups a user is in.



Syntax[edit]

static getUserGroups($userId)
Parameter Name Default Value Description
$userId $userId The id of the user.

Returns[edit]

mixed Array on success, on error.

Defined in[edit]

libraries/joomla/user/helper.php

Importing[edit]

jimport( 'joomla.user.helper' );

Source Body[edit]

public static function getUserGroups($userId)
{
        // Get the user object.
        $user = &JUser::getInstance((int) $userId);

        return isset($user->groups) ? $user->groups : array();
}



Examples[edit]

Code Examples[edit]