$user->groups does not contain group names

Joomla versions 2.5, 1.7 and 1.6 are all end-of-life since December 31st 2014 and are no longer supported. Please use Joomla 3.x instead.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
Nova123
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Aug 21, 2012 6:13 pm

$user->groups does not contain group names

Post by Nova123 » Tue Aug 21, 2012 7:23 pm

In Joomla 1.7 I had the following code to check that the user had enough access to view a particular feature:

$user = JFactory::getUser();
$hasAccess = array_key_exists("EventPublisher", $user->groups);

In Joomla 2.5.6, only the group id is stored in the array. These methods yield similar results in 2.5.6:
JAccess::getGroupsByUser($user->id);
JFactory::getUser()->getAuthorisedGroups();

How do I determine if the user belongs to the "EventPublisher" group now?

Locked

Return to “Migrating and Upgrading to Joomla! 2.5”