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

AsyncPiMaker22485
AsyncPiMaker22485

I would like for various users to be able to publish pages that have explicit permissions by user group. Is there a plugin that already does this? If not, any code examples demonstrating a similar concept?

More detail 1) User with proper permissions creates new page. 2) Upon completion, they select user group(s) authorized to view this page. It would be nice to have a public group (no login) as an option. 3) These permissions would affect whether you see it with the direct URL or as part of a blog page list.

I diligently searched, but found nothing quite like this scenario. Perhaps I used incorrect terminology as I am new to this CMS. BTW, I really like a lot of what I do see and plan to use on several new projects this year.

jlongo
jlongo

Well, one possibility i've used is bellow (for the case it's used on menu partial, but can be used in anywhere - layouts, pages, partials)

users not logged see this as the ones logged
    {% if user %}
            {% if user.groups.0.id == 7 %}
                <li class="treeview">
                    ...only admins see this 
                </li>
            {% endif %}
            {% if user.groups.0.id >= 6 %}
                <li class="treeview">
                    ...only admins and other group see this
                </li>
            {% endif %}
            {% if user.groups.0.id >= 3 %}
                ....only users with group id equal or greater than see this
            {% endif %}
            logged users can see this
  {% endif %}

Just get the id's and/or adjust as needed. I hope that helps

JL

Last updated

1-2 of 2

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