User-profile Tag
Fetching user data made easy.
Overview#
The user:profile
tag has access to all of a user's basic data. Passwords and hashes are not available through this tag.
This will default to the currently logged in user if none are specified.

Shorthand#
You can use user
and drop the :profile
bit off if you prefer.
Examples#
To output the currently logged in user's details, you can do this:
{{ user }}
The current user's name is {{ name }}.
{{ /user }}
<s:user>
The current user's name is {{ $name }}.
</s:user>
{{-- Aliasing the user. --}}
<s:user
as="user"
>
The current user's name is {{ $user->name }}.
</s:user>
Or perhaps you'd like to show user profile pages. Assuming your users have a username
field, you could create a wildcard route like this:
Route::statamic('users/{username}', 'users.show');
Then when visiting /users/chuck
, for example, you could display Chuck's details like this:
{{ user:profile field="username" :value="segment_2" }}
{{ first_name }} {{ last_name }}
{{ /user:profile }}
<s:user:profile
field="username"
:value="$segment_2 ?? null"
>
{{ $first_name }} {{ $last_name }}
</s:user:profile>
Or to find a user by email:
{{ user:profile :email="email" }}
{{ first_name }} {{ last_name }}
{{ /user:profile }}
<s:user:profile
:email="$email"
>
{{ $first_name }} {{ $last_name }}
</s:user:profile>
Parameters
id
Fetch user by ID.
Fetch user by email.
field
Fetch user by a specific field value. Used with value
below.
value
Value of above field
to fetch user by.
Variables
Variable | Type | Description |
---|---|---|
user data |
mixed |
All user data (except password) is available. |
no_results |
boolean |
|
is_[role] |
boolean |
|
in_[group] |
boolean |
|
Docs Feedback
Submit improvements, related content, or suggestions through Github.
Betterify this page