Data Roots
Data Roots are the top-level context objects available to every expression. They are resolved from WordPress’s current request context server-side.
user
Represents the currently logged-in user (or a guest state if not logged in).
| Property | Type | Description |
|---|---|---|
user.is_logged_in | Boolean | true if the current visitor is authenticated |
user.id | Integer | The WP User ID |
user.name | String | The user’s display name (alias for display_name) |
user.login | String | The username — returns null for anonymous visitors |
user.email | String | The user’s email address — returns null for anonymous visitors |
user.roles | Array | The user’s roles (e.g., ["administrator"], ["subscriber"]) |
user.registered | String | Registration date (raw YYYY-MM-DD HH:MM:SS) |
user.url | String | The user’s profile URL |
user.meta.* | Mixed | Access public user meta by key. Protected meta (_ prefix) and sensitive keys (pass, token, secret, auth, etc.) are blocked |
NOTE
user.email and user.login are gated behind authentication — they return null for anonymous (logged-out) visitors, even if used inside a block with visibility set to logged-in users.
Example:
{{ user.is_logged_in ? user.name : "Guest" }}
{{ user.roles[0] == "administrator" ? "Admin Panel" : "" }}
post
Represents the current post, page, or custom post type in the loop context.
| Property | Type | Description |
|---|---|---|
post.id | Integer | The post ID |
post.title | String | The post title |
post.slug | String | The URL slug (aliased from post_name) |
post.type | String | The post type (e.g., post, page) |
post.status | String | The post status (e.g., publish, draft) |
post.author | Integer | The post author’s user ID |
post.author_name | String | The display name of the post author |
post.date | String | The publish date — raw YYYY-MM-DD HH:MM:SS; use | date to format |
post.content | String | The full post content |
post.excerpt | String | The post excerpt |
post.url | String | The full permalink URL |
post.meta.* | Mixed | Access public post meta by key. Protected meta (_ prefix) and sensitive keys (pass, token, secret, auth, etc.) are blocked |
Example:
{{ post.title }}
{{ post.author_name | upper }} • {{ post.date | date "F j, Y" }}
{{ post.meta.card_type | match event="Workshop" | default "Resource" }}
site
Represents global site-level data.
| Property | Type | Description |
|---|---|---|
site.name | String | The site name (from Settings) |
site.description | String | The site tagline/description |
site.url | String | The site home URL |
site.language | String | The site language code (e.g., en-US) |
Example:
{{ site.name }}
{{ site.url + "/membership" }}
Extensibility
Additional context roots can be registered by developers using the vector_expressions/context/get filter:
add_filter( 'vector_expressions/context/get', function( $value, $root ) {
if ( 'crm' === $root ) {
return [
'company' => get_option( 'crm_company_name' ),
'rep_email' => get_option( 'crm_rep_email' ),
];
}
return $value;
}, 10, 2 );
After registering, the custom root is available in expressions:
{{ crm.company }}
{{ crm.rep_email | default "support@example.com" }}
See Developer Extensibility for details.