Skip to content

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

CapabilityWho Has It
readAll authenticated users
edit_postsContributors and above
publish_postsAuthors and above
edit_others_postsEditors and above
manage_optionsAdministrators only
edit_usersAdministrators only
upload_filesAuthors and above
moderate_commentsEditors 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

RoleDescription
administratorFull site access
editorManage and publish all content
authorPublish and manage own content
contributorWrite drafts, cannot publish
subscriberRead-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

KeyDescription
first_nameUser's first name
last_nameUser's last name
descriptionBiographical info
nicknameUser'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.