0

I'm rather new at CodeIgniter and especially Ion Auth. I'm building a website which will have three tiers of user: User, Moderator and Admin. My aim is to use this code snippet:

        if (!$this->ion_auth->in_group('moderator'))
    {
        //redirect them to the because they must be a moderator
        redirect($this->config->item('base_url'), 'refresh');
    }

to check if user is an administrator before granting access.

I have already edited my 'groups' table as follows:

(ID, name, description) 1 admin Administrator, 2 members General User, 3 moderator Moderators

I have also updated one user in my 'user_groups' table to have 'group_id' of '3'.

However, when I test my code, it will always allow my admin to see the page (which is fine) but it will redirect my moderator.

I haven't changed anything in my ion_auth library file, or any models, but I did manually create and insert into all my tables as MySql didn't like it being loaded.

EDIT: I think it may be connected to my Databases, as I've tried to promote a user to an admin by changing their 'group_id' in the 'users_group' table and my website won't recognize them as an admin. However, I am not receiving any errors, but my code is just not recognizing anyone but the admin.

Thank you in advance for any help you can give - I'm pulling my hair out!!!

Gwenji
  • 117
  • 2
  • 11

1 Answers1

0

I am working with this ION Auth too and works perfectly fine for me. I created also multi- access user. What I did is I modified only the controller. Models and libraries i did'nt touch it.

Can you more elaborate your questions? What do you mean it redirect your moderator (redirect to where).

Give a detailed question.

user2046410
  • 117
  • 4
  • 15
  • I would like to create some pages that only the moderator can access, and if someone tries to access that page and they are not a moderator they will be redirected. I've edited my post, as I think it may be connected with a problem in my DB. – Gwenji Mar 05 '13 at 10:03
  • yes it's the same with me. I created my own function for that. First check the group id in database once it is found it redirect to the page. – user2046410 Mar 05 '13 at 10:08
  • I was updating the wrong user to the new moderator group! Stupid mistake my end! – Gwenji Mar 05 '13 at 12:38