User & Author
Access user data. UnBlock provides two root variables that share the same fields:
user— The currently logged-in visitorauthor— The author of the current post
info
Both user and author expose the same fields listed below. The only difference is which user 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 |
name | — | string | Display name |
login | — | string | Username |
slug | — | string | User slug (nicename) |
email | — | string | Email address |
display_name | — | string | Display name |
first_name | — | string | First name |
last_name | — | string | Last name |
nickname | — | string | Nickname |
description | — | string | Biographical info |
url | — | string | Website URL |
link | — | string | Author archive URL |
path | — | string | Author archive path |
edit_link | — | string | Admin edit URL |
profile_link | — | string | Profile page URL |
avatar | size | string | Avatar URL |
roles | — | array | User roles |
logged_in | — | bool | Is user logged in |
is_current | — | bool | Is the current logged-in user |
can | capability | bool | Check user capability |
can_edit | — | bool | Can edit this user |
meta | field_name | mixed | User meta value |
raw_meta | field_name | mixed | Unescaped meta value |
has_field | field_name | bool | Check if field exists |
Basic Fields
{{ user.id }}
{{ user.name }}
{{ user.login }}
{{ user.email }}
Profile
{{ user.display_name }}
{{ user.first_name }} {{ user.last_name }}
{{ user.nickname }}
{{ user.description }}
{{ user.url }}
URLs
{{ user.link }}
{{ user.path }}
{{ user.edit_link }}
{{ user.profile_link }}
Avatar
{{ user.avatar }} <!-- Default size -->
{{ user.avatar(96) }} <!-- 96px size -->
{{ user.avatar(200) }} <!-- 200px size -->
Roles & Capabilities
{{ user.roles|join(', ') }}
{{ user.logged_in }}
{{ user.is_current }}
{{ user.can('edit_posts') }}
{{ user.can('manage_options') }}
Custom Fields (Meta)
{{ user.meta('phone') }}
{{ user.meta('company') }}
{{ user.meta('billing_address').city }}
{{ user.has_field('phone') }}
Common Patterns
Show content for logged-in users
{{ user.logged_in ? '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.description }}
{{ author.avatar(96) }}
"Posted by" line
Posted by {{ author.name }} on {{ post.date('F j, Y') }}
Author link
<a href="{{ author.link }}">{{ author.name }}</a>