So once you have created different user profiles, how do you define who is allowed to use which component.
Its a follow up from my prev thread about different user levels.
Its a follow up from my prev thread about different user levels.
//restrict user group in this component
$user = JFactory::getUser();
$group = $user->groups[2];
//($group == 2) #2 is the user group id.
//change it according your restricted user group.
if ($group == 2) {
echo "You are not authorized to view this page.";
return;
}
$restrict = array('2','7'); replace '2' with your restricted user group id and delete '7'. It should become: $restrict = array('2'); . Here the screenshot: http://screencast.com/t/yhs3r2RJT . If you have anymore question, please don't hesitate to ask us.
//check for ES task before restricting the user group
if ($task != 'login' && $task != 'logout' && $task != 'registration'){
//restrict user group in this component
$user = JFactory::getUser();
$group = $user->groups;
//set the restricted user group id
$restrict = array('2'); //change this to your user group id. ------------> Line 64
foreach ($restrict as $key => $value) {
if (in_array($value, $group)) {
echo "You are not authorized to view this page.";
return;
}
}
}