clint Posted October 7, 2010 Share Posted October 7, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/215326-user-table-with-different-access-permissions/ Share on other sites More sharing options...
BlueSkyIS Posted October 7, 2010 Share Posted October 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/215326-user-table-with-different-access-permissions/#findComment-1119783 Share on other sites More sharing options...
Solution ignace Posted October 7, 2010 Solution Share Posted October 7, 2010 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')) { Quote Link to comment https://forums.phpfreaks.com/topic/215326-user-table-with-different-access-permissions/#findComment-1119877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.