I have one question,
How can i get User role in Symfony2 Twig.
I Had looking around but I couldn't find it.
Please help, or clue..
Thanks before.
Hendrawan
A simpler option could be to test the role since you have to define them in security.yml :
{% if is_granted('ROLE_ADMIN') %}
Administrator
{% elseif is_granted('ROLE_USER') %}
User
{% else %}
Anonymous
{% endif %}
you can scan your collection roles of User:
{% for role in app.user.roles %}
{{ role }} <br>
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With