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.
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
It needs to be $aclr = new ACLRole();
$ar->getUserRoleNames($current_user->id,true);