0
votes

I have just used and installed IonAuth on my Codeigniter app.

I have setup 3 user groups..

Admin
Members
Media Partners

Would it be possible to redirect each user group to their unique dashboard area rather than the home page?

e.g.

admins log in and are redirected to => /admin/dashboard/
members log in and are redirected to => /users/dashboard/
media partners log in and are redirected to => /media-info/dashboard/

How would I go about this in my auth controller?

Thanks, Dan

2

2 Answers

1
votes

In your login function check the group and redirect accordingly.

function login () 
{
    //Login code
    ...
    //Login Successful
    $user = $this->ion_auth->get_user(); 

    switch ($user->group)
    {
        case ('admin'):
            redirect(site_url('admin/dashboard'), 'refresh');
        break;
        case ('user'):
            redirect(site_url('users/dashboard'), 'refresh');
        break;
        case ('media'):
            redirect(site_url('media-info/dashboard'), 'refresh');
        break;
    }

    ...
}
0
votes

here is mine, if someone looking for using function if

function index()
{
    if (!$this->ion_auth->logged_in())
    {
        // redirect them to the login page
        redirect('auth/login', 'refresh');
    }
    else
    {
    if ($this->ion_auth->in_group('admin'))
    {
        echo "<h1>here is admin</h1>";
    }   
    else if ($this->ion_auth->in_group('user'))
    {
        echo "<h1>here is user</h1>";
    }
    else if ($this->ion_auth->in_group('media'))
    {
        echo "<h1>here is media</h1>";
    }
    else
    {
    echo "nothing happen"
    }
}

Hope it helps someone out there,

NOte : Make sure group your group same like above