Chell's Roost

Blog & gallery of a geeky, anti-lima bean bookworm

Restrict Articles to Specific Users in Joomla 3.4

For a CMS, plugins can conveniently add functionality, but I don’t want to add a plugin for every last little task. Especially when out-of-the-box functionality can accomplish what I want to do.

Joomla is a superb CMS for a variety of purposes. It’s my own choice for one of my websites. For that site, I needed the ability to restrict certain articles to specific, registered users. While one might expect to choose, from the article-creation page, specific users who may view the article, this is not the case. It is possible to select a general access level for the article, but there may be many users who have the same access level. There are quite a few content and member management plugins available, but here is how to set this up without a plugin.

First, create a new group (Users » Groups » Add New Group). If you sell building supplies, and one of the construction companies you deal with is called “Jerry’s Houses,” create a group with that company name. I actually created a subgroup of registered users, to keep things neat, and placed my customer groups under that. That is up to you, and simply requires the creation of the desired groups. Create a separate group for each organization or individual you deal with. Keep in mind that a group may have as many users in it as you want, or only one user. All of Jerry’s employees will ultimately be able to view the content meant only for “Jerry’s Houses,” but other users won’t see that content.

Create an access level (Users » Access Levels » Add New Access Level). You can name it the same as the group name you created. Under “User Groups Having Viewing Access,” select the group that will be able to view the content. So the group, “Jerry’s Houses,” would be selected to have such access for the access level of the same name. Do this for each group you have created.

Now, when you create an article, you can select from the “Access” dropdown to restrict viewing to the desired access level/group. To allow certain users to view the article, make sure you have added them to the appropriate group.

I took this a step further, and set up a “customer area” category, and a menu item that points there. The menu item is only viewable by the subgroup that contains my targeted groups. It (the menu item) is a “blog” of customer area items, and the articles I create for specific groups are placed only in the customer area category.

There is one other thing that made this work well for me. It is off topic, for this post, but handy. Users may need to view files that I upload just for them (specific users), and I want them to only see the files via my website. I created a folder for such files, and restricted access to everything in it via an htaccess file. Only my server can show the files. Then, I enabled iframe tags for the article editor in Joomla (Extensions » Plugin Manager » Editor – TinyMCE). To do this, remove “iframe” from the list of prohibited elements. Now, I can simply place an iframe that contains a selected file in an article.

Although it’s likely possible to get the same result with a plugin, it’s doable with only an understanding of users, groups, and access levels.

Leave a comment

TrackBack URI