Question

I am modifying my PHP network's code to have "user roles" like wordpress here is my plan so far

0 = registred non email verified user
1 = registed and verified email
2 = moderator
3-9 = nothing yet
10= admin

In my PHP code I will use an array like this that will set what a role number does.

$user_role['10']

I was thinking of storing which value a user has in my mysql DB, would this be the best way to store the 10 different role options as an enum or is there a better way or faster way? I read that enum is not the fastest sometimes.

enum('0','1','2','3','4','5','6','7','8','9','10')
Was it helpful?

Solution

I guess INT or TINYINT is enough to store user level (role). Also you may consider multiplting the numbers by 10, so you'll have a space to add more levels in future.

OTHER TIPS

Use bitmasks for permissions / user levels.

See example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top