Return to Previous Page
Without doubt, DNN's role system is a powerful means for customising your site's content. The visibility of every single module on your pages can be configured on the basis of roles. By employing the technique, you can easily display additional content for super users, display some relevant information for your sellers, or hide products already bought from customers on your e-commerce website. But there is one central limitation.
While working on the relaunch of a big international B2B shop running on the DNN CMS platform, we came across one issue: We wanted to create a single role which automatically consists of the members of other roles. However, this isn't possible with DNN's standard role system.
After some considerations, we decided to develop an extension for DNN which integrates smoothly into DNN's powerful role system. The extension hooks into DNN's role system and extends it by dynamically managing role memberships. We quickly noticed that this idea could be thought a bit further: Instead of simply combining users from different roles into a new one, why not use more criteria such as the existence and value of request parameters and cookies, as well as the a user's geo location?
We needed a means that allows an administrator to express rules in a simple, well-known way. We decided to go with XML. Each rule is represented by a simple to use XML tag. We also added the logical operator tags <AND>, <OR>, and <NOT>, so one can combine multiple rules.
An easy example of how to use XML to create a dynamic rule is the following one. It checks if the HTTP GET request parameter "campaign" is set to "google" or if the cookie "goodCustomer" is present. If so, the rule evaluates to TRUE, so the user is added to a specific DNN role. Notice that the <requestParam> rule support regular expressions, so one has maximum flexibility in defining the desired outcome:
<or><requestParam name="campaign" pattern="^google$" method="get" /><cookie name="goodCustomer" /></or>
The result is called DNN Dynamic Roles. The module requires DNN CMS v07.03.00 or newer and can be obtained from the DNN Store.
From time to time, we publish some HOWTOs and tips in our blog. If you have any questions, feel free to contact us.