User Plugin
The user plugin gives you access to user data and logic.
user:logged_in
{{ user:logged_in }}
Checks if a user is logged in or not. Can be used as a tag pair to limit display of certain code to logged in users, or a single tag that returns true
or false
depending on whether the user is logged in.
Attributes
Name | Default | Required | Description |
---|---|---|---|
group | None | No | Group slug. Check if a user is not only logged in, but also a member of the specified group. |
Example
{{ if user:logged_in }}
<p>This is just for logged in users.</p>
{{ endif }}
user:not_logged_in
{{ user:not_logged_in }}
Identical to the previous function, but instead checks to see if a user is NOT logged in. Also takes the group parameter. Must be used in a tag pair.
Single User Profile Variables
The user plugin also gives you access to various user variables using the following syntax:
{{ user:variable }}
These calls default to the current logged in user, but you may also specify a user's ID with the optional user_id parameter:
{{ user:variable user_id="4" }}
If you are using custom stream fields that return multiple records, you can access the values within as a tag pair:
{{ user:country }}{{ name }}{{ /user:country }}
Below is a table of variables that are hard-coded into the system and always available.
Variable | Notes |
---|---|
id | |
group_id | |
ip_address | |
active | 1 or 0. |
activation_code | |
created_on | Unix epoch format. |
last_login | Unix epoch format. |
username | |
display_name | |
forgotten_password_code | |
remember_code | |
group | Group slug. |
group_description | Group name. |
user:profile
Aside from accessing user profile fields individually, you can also access them using the profile function. Inside the tag pair, you can access any of the user profile variables, including your custom fields.
{{ user:profile }}
{{ display_name }}
{{ custom_field }}
{{ custom_field:sub_value }}
{{ /user:profile }}
The profile tag also takes an optional user_id value.
{{ user:profile user_id="4" }}
user:profile_fields
In the event you want to just show all user profile data in a list, you can do so with this function. Each piece of user data can be accessed via the following variables:
Variable | Notes |
---|---|
value | Field value. For user profile fields that return multiple values, this will be the alternate canonical display that field types can and should provide. |
name | Field name. |
slug | Field slug. |
{{ user:profile_fields }}
<p><strong>{{ name }}: {{ value }}</strong></p>
{{ /user:profile_fields }}