How do I show a template according to the login user by groups idand how do I restrict access to the controller according to user groups.
My controller :
public function index()
{
if (!$this->ion_auth->in_group('admin'))
{
$this->template->administrator('dashboard/dashboard');
}
elseif (!$this->ion_auth->in_group('2'))
{
$this->template->admin('dashboard/dashboard');
}
elseif (!$this->ion_auth->in_group('3'))
{
$this->template->user('dashboard/dashboard');
}
elseif (!$this->ion_auth->in_group('members'))
{
$this->template->client('dashboard/dashboard');
}
else
{
redirect('account/sign_in', 'refresh');
}
}
After trying and asking, finally I get the correct results that I can use as in the following code :
public function index()
{
if (!$this->ion_auth->logged_in())
{
redirect('account/sign_in', 'refresh');
}
elseif ($this->ion_auth->is_admin())
{
$this->template->administrator('dashboard/dashboard');
//View to Administrator
}
elseif($this->ion_auth->in_group('admin'))
{
$this->template->admin('dashboard/dashboard');
//View to Admin
}
elseif($this->ion_auth->in_group('user'))
{
$this->template->user('dashboard/dashboard');
//View to User
}
else
{
$this->template->client('dashboard/dashboard');
//View to Client
}
}
Hopefully this answer helpful and enjoy time to code...... :)