Tuesday, March 11, 2008

CF8 IsUserInAnyRole function

In CF8, a new function was added, IsUserInAnyRole()
Description: Determines whether the logged in user belongs to any Role.
 
Returns: True, if the logged in user, belongs to any Role; False, otherwise.
 
Syntax:
 
IsUserInAnyRole(param1, param2, param3...)
 
Usage:
The function "isUserInAnyRole" takes a comma separated list as input. This can be a single parameter also. 
The result will be an OR function on the list of roles.  The role names are not case-sensitive.
To check if a user is in multiple roles, specify them in a comma-delimited list, such as "admin,user1,user2"
Examples
 
<cfoutput>isUserInAnyRole("admin")? #isUserInAnyRole("admin")#</cfoutput><br><br>
            This will return true if the current logged in user has "admin" roles.
 
<cfoutput>isUserInAnyRole("admin,user1,user2")? #isUserInAnyRole("admin,user1,user2")#</cfoutput><br><br>
            This will return true if the current logged in user has "any" of the three roles "admin, user1, user2" roles.

No comments:

Post a Comment