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 trialSteve Meadows
Full Stack JavaScript Techdegree Student 15,218 PointsAdding 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
Treehouse TeacherHi , 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!
Steve Meadows
Full Stack JavaScript Techdegree Student 15,218 PointsSteve Meadows
Full Stack JavaScript Techdegree Student 15,218 PointsThank 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