Jump to content

User table with different access permissions


clint

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.

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')) {

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.