juser($id = null)
This function is a proxy of Joomla\CMS\Factory::getUser()
. It allows to retrieve users to use them inside twig layouts.
Parameters
integer
$id [optional] User to load. Default: use active user
Returns
Joomla\CMS\User\User
The User object.
Examples
{# Retrieve active user not using any id. This is not usually required because you can already use `juser` global var #}
{% set activeUser = juser() %}
{# Retrieve the user with id: 668 #}
{% set user = juser(668) %}
{# Let's test if user was found #}
{% if user.get('guest') %}
User could not be loaded
{% else %}
User found with email: {{ user.email }}
{% endif %}