PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Helper / API Basic

Get the Logged-In User with $app->getIdentity() (Replaces JFactory::getUser)

Reads ID, name, email, groups and guest status of the active user using the native Joomla 5 and 6 Identity API.

Updated on 24 November 2026 71 copies 243 views
templates/seu_template/index.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;

$user = Factory::getApplication()->getIdentity();

if ($user && !$user->guest) {
    $userId   = (int) $user->id;
    $userName = (string) $user->name;
    $groups   = $user->getAuthorisedGroups();
    $levels   = $user->getAuthorisedViewLevels();
}
Always check !$user || $user->guest before exposing authenticated UI.
templates/seu_template/index.php
<?php
$user = JFactory::getUser();
if (!$user->guest) {
    echo $user->name;
}
Legacy Joomla 3 snippet calling JFactory::getUser().

Technical explanation and best practices

Factory::getUser() was deprecated and removed in Joomla 6. Always call Factory::getApplication()->getIdentity() for the active session user, and UserFactoryInterface when loading another user by ID.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.