Get the Current User Role – SugarCRM / SuiteCRM

There was a requirement from client where he wants validation based on user role. So we need to check login user (current user) role name and put validation on it. This can be achieved by using below simple steps.

we can get the current user role using the following code,

global $current_user;
include_once(‘modules/ACLRoles/ACLRole.php’);
$ACLRole = new ACLRole();
$roles = $ACLRole->getUserRoleNames($current_user->id);
echo "<pre>";
print_r($roles);

Hope you find this blog post helpful.

Feel free to add comments and queries, that helps us to improve the quality of posts.

You can contact us at info@infotechbuddies.com

Thank you.

Spread the love

2 thoughts on “Get the Current User Role – SugarCRM / SuiteCRM

  • Jay Khatal

    global $current_user;
    include_once(‘modules/ACLRoles/ACLRole.php’);
    $aclRole = new ACLRole();
    $roles = $aclRole->getUserRoleNames($current_user->id);
    echo “”;
    print_r($roles);

    You forgot to create the object of that class

Leave a Reply

Your email address will not be published. Required fields are marked *