简体   繁体   中英

PHP Code Igniter Ion Auth - Can't successfully create a new tier of user

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!!!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM