Description

Determines whether an authenticated user belongs to the specified Role.

Returns

True, if the authenticated user, belongs to the specified Role; False, otherwise.

Category

Function syntax

IsUserInRole("role_name")

See also

cflogincfloginuserGetAuthUserGetUserRolesIsUserInAnyRoleIsUserLoggedInSecuring Applications in the Developing ColdFusion Applications

History

ColdFusion MX: Added this function.

Parameters

Parameter

Description

role_name

Name of a security role

Usage

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,HR". Lists with multiple roles cannot contain spaces as separators; for example, do not use "Admin, HR".

Example

<cfif IsUserInRole("Admin") > 
<cfoutput>Authenticated user is an administrator</cfoutput> 
<cfelse IsUserInRole("User") > 
<cfoutput>Authenticated user is a user</cfoutput> 
</cfif>

Note:

From ColdFusion 11 onwards, this function is not applicable when a user is logged in using Admin API. 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy