Back to UserHelper class

Method getUserGroups

public static array
getUserGroups
(mixed $userId)
Method to get a list of groups a user is in.
Parameters
  • int $userId The id of the user.
Returns
  • array List of groups
Since
  • 1.7.0
Class: UserHelper
Project: Joomla

Method getUserGroups - Source code

/**
 * Method to get a list of groups a user is in.
 *
 * @param   integer  $userId  The id of the user.
 *
 * @return  array    List of groups
 *
 * @since   1.7.0
 */
public static function getUserGroups($userId)
{
    // Get the user object.
    $user = User::getInstance((int) $userId);
    return $user->groups ?? array();
}