Composr Supplementary: Using the if_in_group in Composr
Written by Steve Jarvis, Sponsored by Arvixe hosting
Potentially Outdated Tutorial
This supplementary tutorial might be outdated as it was written for a previous version of Composr CMS (version 10).
One thing I love about Composr is the infinite customisation ability of the software, and a very useful piece of code is the if_in_group tag which allows you to specify different things to happen depending on which group the user is in. You can display a message to guests and a different message to members. The tag allows you to use Composr's Comcode to display blocks of information or different content to your members.
An example of this is you might want to display a gallery on the homepage to premium members but not anyone else. (You could also do this with permissions.)
Using the if_in_group tag on a page
There are two types of places you might want to use the if_in_group tag. One of them is on a normal page which you edit in the normal way. The second is as part of the website template which I will cover further down. To add the code to a normal page you will need to use the example below:Code
[if_in_group="1,2,6,7"]Here would be a custom welcome message which only members of groups 1, 2 6 & 7 would see[/if_in_group]
[if_in_group="3,4,5,8"]Here would be a custom welcome message which Members of groups 3,4,5 & 8 would see[/if_in_group]
In this example you can see there would be two different messages displayed to 2 different sets of usergroups. You could add as many different as you like. If you only want a message for guests you would just use group 1. If you want to show another message to everyone else, rather than add each number in turn (2,3,4,5,6, …) you can use 2+ and this will display to every group numbering 2 and higher.
There are quite a few different syntax you can use to customise which groups will see your messages; there is a full list of the syntax here.
Using an equivalent to if_in_group in templates
If you would like to use the if_in_group tag on a template, the code will change a little as the templates in Composr use Tempcode rather than Comcode. An example of what the code would look like is below. In this example the text would appear if the user was logged in and a member of group 7 or above:Code
{+START,IF,{$IS_IN_GROUP,7+}}
What you want to appear goes here
{+END}
Feedback
Please rate this tutorial:
Have a suggestion? Report an issue on the tracker.