Skip to main content
2 of 2
Added "isCurrent" explanation
Lindsey D
  • 24.1k
  • 5
  • 54
  • 111

To determine if the user is logged in at all, you'll want to use the currentUser variable:

{% if currentUser %}
    Welcome, {{ currentUser.friendlyName }}!
{% endif %}

To determine if the logged in user is a specific user, then simply compare against their username:

{% if currentUser and currentUser.username is 'johndoe' %}
    Hey Johnny Boy!
{% endif %}

The isCurrent method is useful when targeting a more generic UserModel (where you don't know if the user would be the current user).

{% for user in craft.users %}
    {% if user.isCurrent %}
        {{ user.friendlyName }} is you!
    {% else %}
        {{ user.friendlyName }} is someone else.
    {% endif %}
{% endfor %}
Lindsey D
  • 24.1k
  • 5
  • 54
  • 111