A request that comes up quite often is how to redirect a user from a page in Telligent Community. There are several reasons you might want to do this;

  1. When you have a group as a container with no content e.g. a ‘Products’ group when you don’t want to show the product group, but require it for page hierarchy.
  2. You might want to secure something like a custom page for users in a particular role.
  3. You might to check if a user is a paid member to access the site so you want to redirect users that aren’t to a sign up page.

The way we handle this in Telligent Community is with a very simple widget, in which you can hard code the rules for your widget, or optionally, you can make the widget configurable. To start off, we are going to go to the Administration are of Telligent Community, select ‘Interface’ and then ‘Widgets’. From here you can click on the ‘+’ icon to create a new widget. We’re going to call ours ‘Redirect Widget’.

We’re then going to configure the widget by turning off the default header and enable caching including vary cache by user, as highlighted in the screenshot above. We can now publish the widget.

Next, we’re going to edit the widget content to add our logic to redirect the user. For this example we’ll redirect any user that isn’t in the Administrators role. We might use this on a content page we’ve created and dropped reporting widgets onto, so we want to restrict access to the page to only users with admin rights. The code below get’s the accessing user, then checks their role. If the check is no successful, we’ll redirect them to the home page.


#set ($isUserAdmin = false)
#set ($isUserAdmin = $core_v2_roleUsers.IsUserInRoles($core_v2_user.Accessing.Username, $core_v2_utility.MakeList(“Administrators”)))


Firstly, we are going to check that the widget isn’t in preview mode. If it is then we might block ourselves from editing the page in future if the user trying to edit the page is caught by this rule. We then set our flag to false so even if the call to IsUserInRoles call fails, the user won’t pass the check. Then we pass in the username for the accessing user and call the $core_v2_utility.MakeList function to make out IList that we need to pass into the check.

Based on the result, we’ll then redirect the user if they are not the required role. This can easily be extended to make the redirect URL configurable, or to allow the widget to be configured to set the roles to allow or deny.

Leave a Reply