Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP User Authentication Setting up Authorization System Series Summary

Steve Meadows
seal-mask
.a{fill-rule:evenodd;}techdegree
Steve Meadows
Full Stack JavaScript Techdegree Student 15,218 Points

Adding additional user Roles

How would you go about adding additional user roles to the system? I have my admin role and user role but would like to add another to it.. any help would be appreciated

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi , Steve Meadows! I'm just following up here. I know we talked about this in the Techdegree slack. In this example, Alena is using a pretty simple system. A user with role_id of 1 is an admin. Any other user has a role_id of 2. If you wanted to create new types of user roles, you could just include different numbers like 3, 4 and 5 and customize your if else or switch statements to base the results based on the role_id.

However, if you had that many "roles", I'd advocate for breaking that out into a Roles table such that the role_id is a foreign key that points to that table.

Hope this helps! :sparkles:

Steve Meadows
seal-mask
.a{fill-rule:evenodd;}techdegree
Steve Meadows
Full Stack JavaScript Techdegree Student 15,218 Points

Thank you very much for all your help.. I decided to use sessions in the end and works perfectly.. once I have learned more about cookies I think I will change it but for now sessions lol