Jump to content

User table with different access permissions


Go to solution Solved by ignace,

Recommended Posts

Hello,

Could somebody please advise me on the following. Not a "show me how to do it" otherwise I will never learn but reference to what I should be studying to get the following question right....

 

I would like to know what is the best way to set up a users table if there are more than 1 type of user.

For example: a free user that can add profile info and a paying user that can add profile info as well as add comments to a comments table. If the user logs in the free user will not have the option (say a link to add comment page) displayed on their profile page.

 

So basically when you register you can select either free or paying user. Once you are registered, the paying user has the option to add comments from profile page.

 

Now, do I add both types of users to the same users table in the db and set the privileges on the comment table? What should I be looking up to get this right?  :-\

 

Thanks in advance for your time. Much appreciated!

based on the user permissions, show and/or hide options via PHP. Don't show all options and allow MySQL to determine whether or not the user can modify the data. Use PHP to show and/or hide options and verify the user permissions before allowing an update.

  • Solution

You are looking for an Access-Control List (ACL). If you want to assign permissions on a per-user basis you can use:

 

user (id)

resource (id)

acl (user_id, resource_id, permission)

 

If you want to make it for a group of users:

 

user (id, role_id/group_id)

role/group (id)

resource (id)

acl (role_id/group_id, resource_id, permission)

 

Where permission is allow/deny and a resource can be something like 'add_comment'. In your application you can then add something like:

 

 

if($acl->isAllowed('add_comment')) {

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.