am a beginner in codeigniter, a working on this system with multiple users such as academic, bursar, headmaster, director etc. What i want is every user to be directed to his own page according to his role. This is what i have done so far
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) {
//if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
$user = $this->ion_auth->get_users_groups()->result();
switch ($user->name)
{
case ('admin'):
redirect(site_url('admin/index'), 'refresh');
break;
case ('academic'):
redirect(site_url('academic/dashboard'), 'refresh');
break;
case ('headmaster'):
redirect(site_url('headmaster/dashboard'), 'refresh');
break;
}
}
I get this error Message: Trying to get property of non-object
Also trying
switch($user['name'])
lead to undefined index 'name'