This bolt.cm extension adds some twig helper functions to work with Bolt users in your templates.
- Login to your Bolt installation
- Go to "Extend" or "Extras > Extend"
- Type
twig-user-helper
into the input field - Click on the extension name
- Click on "Browse Versions"
- Click on "Install This Version" on the latest stable version
The users()
function returns all registered users. They are sort by ID and contain even disabled users.
{% for user in users() if user.enabled %}
{{ user.displayname }} <br>
{% endfor %}
You can also order them by username or any other key on the user object.
{% for user in users()|order('username') if user.enabled %}
{{ user.displayname }} <br>
{% endfor %}
The user()
function returns a single user array, or null
if no user was found.
It accepts an ID, an username or an email address as parameter.
{% set user = user(7) %}
{% set user = user('phillipp') %}
{% set user = user('user@email.com') %}
This Bolt extension is open-sourced software licensed under the MIT license