« Back to Product

Documentation

IPS_UserHasRole

 bool IPS_UserHasRole (string $User, string $Role) 

Parameters

User

Name of the user (case-sensitive)

Role

Name of the role to be checked (case-sensitive)

Returns

If the role is assigned to the user, TRUE is returned, otherwise FALSE.

Description

The function checks whether the role Role is assigned to the user User. The role itself does not need to exist.

For the @admin user the function returns TRUE for every role, for the special user @unknown always FALSE. If the user does not exist, the function fails with "User with name '…' does not exist". The function requires neither the RBAC feature in the license nor administrator permissions.

See also: IPS_AddRoleToUser, IPS_UserIsAdministrator

Example

if (IPS_UserHasRole('anna', 'visu')) {
    echo 'Anna has the role visu';
}
Any questions?