Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Apollyon's avatar

Roles and Permissions based on group

Hi, I am in a bit of distress, so hope you guys have some solutions.

I want to build up a roles and permission system, that depends on which group you are in.

User 1:

  • Group 1
    • Admin
  • Group 2
    • User

User 2:

  • Group 1
    • Developer
  • Group 2
    • Reviewer

How can this be achieved best? I can't find any guidance with simply google searches. I cannot, for the life of me, figure this one out :)

0 likes
4 replies
jlrdw's avatar

They are all users, what I generally do is add more columns to my users table as needed. And you could have group 1 - 4

Apollyon's avatar

But that would not work properly, just adding more fields to the users table, as they can be in many groups with different roles.

jlrdw's avatar

I suppose you could have a related group table, not sure what to name it, then the added columns in users would identify what group and role a user has.

extjac's avatar

I would do it like this....

User 1 (create a users_roles table if you can have more than 1 role, or just a role_id under the users table)
- User Role (roles or groups table)
--- Add (roles_permissions table)
--- Update (roles_permissions table)

User 2:
- Reviewer Role  (roles or groups table)
--- Review (roles_permissions table)
--- Approve (roles_permissions table)

User 3:
- Admin Role
--- Add (roles_permissions table)
--- Update (roles_permissions table)
--- Review (roles_permissions table)
--- Approve (roles_permissions table)

Please or to participate in this conversation.