User
Access user data. The user root provider represents the currently logged-in visitor and is available on all pages.
The author variable uses the same provider but resolves to the post's author instead. See the overview for details.
user and author expose the same fields listed below. The only difference is which person they point to: user is whoever is viewing the page, author is whoever wrote the post.
All Fields
| Field | Arguments | Returns | Description |
|---|---|---|---|
id | — | int | User ID |
slug | — | string | User slug (nicename) |
user_email | — | string | Email address (private) |
display_name | — | string | Display name |
name | — | string | Display name (alias of display_name) |
user_url | — | string | Website URL |
link | — | string | Author archive URL |
path | — | string | Author archive path |
edit_link | — | string | null | Admin edit URL (null when not authorized) |
profile_link | — | string | null | Same as edit_link |
avatar | {args} | string | Avatar URL |
roles | — | array | null | User roles, null when no roles (private) |
is_current | — | bool | Is the current logged-in user |
can | capability, ...args | bool | Check user capability (private on another user than the visitor) |
can_edit | — | bool | Can edit this user |
meta | field_name | mixed | User meta value (also used for first_name, last_name, nickname, description); private except the names, nickname and bio |
raw_meta | field_name | mixed | Meta value, without plugins |
has_field | field_name | bool | Check if field exists |
user_login, user_email, user_registered, roles, and user meta (except first_name, last_name, nickname and the bio, description) show nothing until the site opens them in Settings > Privacy, whoever wrote the expression. A logged-in visitor always reads their own. Users without a published post, such as customers, are private as a whole. See Private Data.
Raw Database Fields
Direct read access to the underlying WP_User columns:
| Field | Returns | Description |
|---|---|---|
ID | int | User ID (alias of id) |
user_login | string | Username (private) |
user_nicename | string | URL-friendly slug (alias of slug) |
user_registered | string | Registration date YYYY-MM-DD HH:MM:SS (private) |
Profile
Profile fields like first/last name, nickname, and biographical info are accessed through meta() (matching how WordPress stores them). These are public, as are the user fields made with ACF, Meta Box, Pods or JetEngine (password fields aside); other user meta is private until its key is opened in Settings > Privacy:
{{ user.display_name }}
{{ user.meta('first_name') }} {{ user.meta('last_name') }}
{{ user.meta('nickname') }}
{{ user.meta('description') }}
{{ user.user_url }}
Avatar
The avatar field takes an options object, the arguments of get_avatar_url(), as in Timber:
{{ user.avatar }} <!-- Default size (96px) -->
{{ user.avatar({size: 200}) }} <!-- 200px size -->
{{ user.avatar({size: 200, default: 'identicon'}) }} <!-- Custom options -->
Roles & Capabilities
{{ user.roles|join(', ') }}
{{ user.is_current }}
{{ user.can('edit_posts') }}
{{ user.can('manage_options') }}
{{ user.can('edit_post', post.id) }} <!-- Variadic — pass extra args for meta-capabilities -->
To check whether a visitor is logged in, test user.id (it's empty for guests):
{{ user.id ? 'Welcome back!' : 'Please log in' }}
Custom Fields (Meta)
{{ user.meta('phone') }}
{{ user.meta('company') }}
{{ user.meta('billing_address').city }}
{{ user.has_field('phone') }}
meta('key') integrates with ACF, MetaBox, JetEngine, and Pods. User meta keys are private until opened in Settings > Privacy; keys starting with _ are always blocked.
Common Patterns
Show content for logged-in users
{{ user.id ? 'Welcome back!' : 'Please log in' }}
Display user greeting
Hello, {{ user.name ?? 'Guest' }}
Check admin capability
{{ user.can('manage_options') ? 'Admin Panel' : '' }}
Author bio
{{ author.name }}
{{ author.meta('description') }}
{{ author.avatar({size: 96}) }}
"Posted by" line
Posted by {{ author.name }} on {{ post.date('F j, Y') }}
Author link
<a href="{{ author.link }}">{{ author.name }}</a>