Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 283943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:24:59+00:00 2026-05-12T05:24:59+00:00

The site I am working with has a somewhat convoluted way with dealing with

  • 0

The site I am working with has a somewhat convoluted way with dealing with users and permissions.

These are the user types:

  • User
  • Facility Approver
  • Facility Admin
  • Corporate Approver
  • Corporate Admin

Now there are also facilities, and that is where these permission levels come into play. Facilities are linked to users and user levels in a table like such:

user_id     facility_id     userlevel
joebob      ABCInc          Facility Admin

Pretty simple so far, but now what I want is be able to allow one user level to set restrictions on another user level for a certain facility. For example, I’m the Facility Admin and I want to only allow Users to submit certain forms. How would I store this?

I was thinking a new table that links facility_id, userlevel and permissionlevel. But what exactly would permissionlevel be? An int? Or would I add columns to the table like canOrderThings or canSearchForStuff?

I was seeing if like this would work, but it seems like it would get a tad messy and hard to keep track if you have a large number of permissions. How would you add permission levels without throwing everything out of wack? Or even setting permission levels would be a bit challenging I think.

Also user levels are directly linked to users in the User Table, but those server different purposes.

Is there a completely better way to structure all of this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:24:59+00:00Added an answer on May 12, 2026 at 5:24 am

    Using a second table for options is a good idea. Some forum frameworks use this method.
    Each of your users are given a UserGroupId which is usually an Int since they are easiest to work with. UserGroupId of 1 for instance, could be an admin, 2 could be a teacher (depends on your organization).

    Then you have a table called Permissions, on this table you include all options as Columns, something like this.

    UserGroupID --|-- SearchEnabled --|-- CanOrder
                 1                   0           1
                 2                   1           1
    

    Using a simple binary system, 1 enabled, 0 disabled, you can control options for each user group. This allows you to get all permissions with a single query, while still offering a very large area for customization.

    You don’t have to use binary numbers though. For instance you could use values 1,2,3 where 1 is full permission, 2 is partial, and 3 is zero. It depends on how specific your regulations need to be.

    Now before you allow a user to perform an option you do a simple check on the users permissions (which you should store in an array or a class for quick access). For a function that enables search you would use a condition such as

    If ($user['SearchEnabled')
    {
       $generate->SearchOptions();
    }
    else 
    {
       $generate->Error('NoSearchPermissions');
    }
    

    Using binary numbers has the obvious benefit of simply check if TRUE or FALSE. If you use a different numbering system it would require a bit more work, checking the specific value
    If ($user['SearchEnabled'] == 2 || $user['SearchEnabled'] == 1)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The site I am working on has the concept of a User and a
I have a Rails 3 site I'm working on that has users who operate
A site I'm working on has Flash headers (using swfobject to embed them). Now
I have this classic ASP site which has been working fine until we updated
I have google analytics set on a site I'm working on, It has a
I have an enquiry form on a site, which has been working for a
I'm working on a site that has a requirement to share session between a
I'm working on a site that still has a lot of scripts in ColdFusion.
I'm working on a site that has about 3,000-4,000 dynamically generated pages, and I'm
I'm working on a database site now that has the URL structure: example.com/f.php?id=12 I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.