Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在ion auth中检索组名以进行重定向_Php_Codeigniter_Authentication_Ion Auth - Fatal编程技术网

Php 在ion auth中检索组名以进行重定向

Php 在ion auth中检索组名以进行重定向,php,codeigniter,authentication,ion-auth,Php,Codeigniter,Authentication,Ion Auth,我是codeigniter的初学者,在这个系统上有多个用户,如学术、bursar、校长、导演等。我希望每个用户根据自己的角色指向自己的页面。这就是我到目前为止所做的 if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) { //if the login is successful //redi

我是codeigniter的初学者,在这个系统上有多个用户,如学术、bursar、校长、导演等。我希望每个用户根据自己的角色指向自己的页面。这就是我到目前为止所做的

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;
                        }
        }
我得到这个错误 消息:正在尝试获取非对象的属性

也在努力

switch($user['name'])

导致未定义的索引“name”

确定我得到的解决方案已经使用$user=$this->ion\u auth->get\u users\u groups()->row()->name;切换($user)而不是$user=$this->ion\u auth->get\u users\u groups()->result();我以前使用过的开关($user->name)。请注意这个答案-Ion Auth的设计目的是允许多个用户组访问一个用户,因此,当以后有人添加新逻辑时,今天的工作可能会中断。最好返回一个结果\u array()并检查是否在\u array()中