API16

API16:JUserHelper/getUserGroups

From Joomla! Documentation

Revision as of 02:16, 25 March 2017 by JoomlaWikiBot (talk | contribs) (preparing for archive only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

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



Syntax

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

Returns

mixed Array on success, on error.

Defined in

libraries/joomla/user/helper.php

Importing

jimport( 'joomla.user.helper' );

Source Body

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

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



Examples

Code Examples