且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Ion Auth在Codeigniter中创建用户角色和配置文件

更新时间:2022-10-16 23:12:42

我以前也有同样的问题,我最后做的是建设关系表来处理具有不同字段的不同组。然后我修改了profile()代码,根据用户的组设置加入附加关系表。



我将开始构建一个关系数据库。 p>

例如:

  **志愿者表** 
id
user_id
语言

**组织表**
id
user_id
任务

然后根据用户组,加入profile()函数中的表。



帮助!


I'm using Codeigniter with Ion Auth for user management. I'd like to create two different user roles - one for volunteers and one for organizations. I know that I can use Ion Auth's groups for things like access control, but what would be a good way to add fields to the different user types (for instance - the volunteer user will have a 'languages spoken' field while the organization will have a 'mission' field)? Should I extend the Ion Auth class for each new user type and handle CRUD seperately for each type, or use the 'groups' field and the user id to reference the fields in another table? Any insight as to an approach to this common problem?

I had the same problem before, what I ended up doing was building relation tables to handle different groups with different fields. Then I modified the profile() code a bit, to join the additional relation table according to the user's group settings.

I would start off building a relational database.

example:

**volunteers table**
id
user_id
languages

**organizations table**
id
user_id
mission

Then depending on user group, join the table in profile() function.

Hope this helps!