Appearance
Auth Functions
Auth functions check the current WordPress user's authentication state, roles, and capabilities. They are useful for conditional rendering, permission-based visibility, and personalized content.
user_can
Checks if the current user has a specific WordPress capability.
Signature: user_can(capability)
Returns true or false.
`{ {user_can('edit_posts') ? 'Editor Access' : 'Read Only'}}`Common Capabilities
| Capability | Who Has It |
|---|---|
read | All authenticated users |
edit_posts | Contributors and above |
publish_posts | Authors and above |
edit_others_posts | Editors and above |
manage_options | Administrators only |
edit_users | Administrators only |
upload_files | Authors and above |
moderate_comments | Editors and above |
Use in visibility rules
In the style editor's visibility settings:
user_can('manage_options')This shows the element only to administrators.
Use in If/Else conditions
condition: "user_can('edit_posts')"user_has_role
Checks if the current user has a specific WordPress role.
Signature: user_has_role(role)
Returns true or false.
`{ {user_has_role('administrator') ? 'Admin Panel' : ''}}`Common Roles
| Role | Description |
|---|---|
administrator | Full site access |
editor | Manage and publish all content |
author | Publish and manage own content |
contributor | Write drafts, cannot publish |
subscriber | Read-only access |
Checking multiple roles
Use logical operators:
user_has_role('administrator') or user_has_role('editor')user_meta
Reads a meta value for the current user.
Signature: user_meta(key)
Returns the meta value (string), or null if the user is not logged in or the meta key does not exist.
`{ {user_meta('phone')}}`
// "+1-555-0123"
`{ {default(user_meta('company'), 'No company')}}`
// "Acme Corp" or "No company"Common user meta keys
| Key | Description |
|---|---|
first_name | User's first name |
last_name | User's last name |
description | Biographical info |
nickname | User's nickname |
Any custom meta key set by plugins or via update_user_meta() is also accessible.
Examples
Personalized greeting
Welcome, `{ {default(user_meta('first_name'), 'Guest')}}`!Admin-only edit button (visibility rule)
user_can('edit_posts')Role-based content
`{ {user_has_role('subscriber') ? 'Upgrade to unlock premium content' : ''}}`Conditional navigation
`{ {user_can('manage_options') ? '<a href="/wp-admin">Dashboard</a>' : ''}}`TIP
For blocking pipeline execution based on auth (not just hiding UI), use the Require Auth pipeline node. Auth expression functions are for conditional display; Require Auth is for server-side access control.