Get logged in user and role

This code will retrieve the user id of the logged in user. It will then check to see if the user has the CMS Administrator role. I used this logic with a custom field so I could control the ability to edit but it could have many uses where rights are concerned.

  1. #set ($foundUser = $cmsuser.getUserByUserId($session.getAttribute("USER_ID")))  
  3. #if($foundUser)  
  4.     #if($cmsuser.isUserRole($foundUser, "CMS Administrator"))  
  5.         yes  
  6.     #end  
  7. #end  
comments powered by Disqus