This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

info52262
info52262

Hi, All,

I'd like to make some partial to show only for users they belong to group "xyz".

How can I write it in template?

mjauvin
mjauvin
{% if user.inGroup('xyz' ) %}
... 
{% endif %} 
info52262
info52262

https://imgur.com/a/79OAFCI

Thank you for the answer, but I get only the error...

mjauvin
mjauvin

You'd have to share some code and give more information

info52262
info52262

Code is just "Demo" template from October CMS, I created the group "vip" and pasted this code in partial footer:

{% if user.inGroup('vip' ) %}

Some example text for VIP user

{% endif %} 

Then I become that error

Last updated

mjauvin
mjauvin

Is that for the Rainlab.User plugin or backend user?

info52262
info52262

For Rainlab.User

ndcisiv
ndcisiv

I'm pretty sure for the Rainlab.User plugin the code would look something like this.

ndcisiv
ndcisiv

I'm pretty sure for the Rainlab.User plugin the code would look something like this.

{% for group in user.groups %}
    {% if group.name == 'vip' %}
        Some example text
    {% endif %}
{% endfor %}

Last updated

info52262
info52262

It works! Thanks a lot

ndcisiv said:

I'm pretty sure for the Rainlab.User plugin the code would look something like this.

{% for group in user.groups %} {% if group.name == 'vip' %} Some example text {% endif %} {% endfor %}

1-10 of 10

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.