Skip to content

Checking Community Roles in Liferay Themes

September 16, 2010

Here is small snippet of code to check community level role in Themes. You can write the following code in init_custom.vm

#* Check for Community role for logged in user. *#
#set ($blogEditorCummunityRole = 'Blog Editor')
#set ($userHasBlogEditorRole = 'false')
#* Get Role Local Service *#
#set ($roleLocalService = $serviceLocator.findService("com.liferay.portal.service.RoleLocalService"))
#* Get All community Level Role for current community and Current Logged In User *#
#set ($communityRolesforUser = $roleLocalService.getUserGroupRoles($user_id,$group_id))
#* Iterate through the list of roles and Compare the Blog Editor Role *#
#foreach ($communityRoleforUser in $communityRolesforUser)
         #if ($communityRoleforUser.getName() == $blogEditorCummunityRole)
               #set ($userHasBlogEditorRole= 'true')
          #end
#end
About these ads
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: