{{ user }}

{{ user }}

The user object is available on every page, and contains all available information about the user who requested the current page. Note that most of these properties are only meaningful if the site has enabled front-end login and the user is currently logged in.

The user object is one of a handfull of simple mechanisms to enable personalization on your site. Used well, these can be powerful tools for developers and website owners.

Properties

Field Type Description
object_type string Will always be "user".
is_valid true/false True if the user is logged in.
guid guid The unique identifier for the user.
guest true/false True if the user is not logged in.
visitor true/false Alias for guest.
logged_in true/false True if the user is logged in.
login_date date The time that the user logged in to the site (in UTC).
properties list The full list of custom properties that have been set for the current user. This list only includes the keys, the values will have to be retrieved using the keys.

Individual custom properties for the user may be accessed using {{ user.propertyName }} or {{ user['propertyName'] }} syntax.

You may also treat this object as a list containing all of the property names which may be iterated using a {% for %} loop. For more details, see the examples below:

Examples

Check if a user is logged in

Copy
{% if user.logged_in %}

Do something

{% else %}

Do something else

{% endif %}

Working with specific custom properties

Copy
{% if user.is_valid %} {% if user.custom_property_name %}

Custom Property: {{user.custom_property_name}}

{% endif %} {% if user['custom_property_name_2'] %}

Custom Property 2: {{user['custom_property_name_2']}}

{% endif %} {% endif %}

List all custom properties for the current user

Copy

User Properties:

    {% for property in user %} --equivalent to {% for property in user.properties %}
  • {{property}} = {{ user[property] }}
  • {% endfor %}