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

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?

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

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

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

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

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

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

For Rainlab.User

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

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

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.