Creating user roles
So far, we have discovered how a view that is accessible to a certain set of admin users can be created easily using the is_accessible()
method. This can be extended to have different kinds of scenarios, where specific users will be able to view specific views. There is another way of implementing user roles at a much more granular level in a model, where the roles determine whether a user can perform all, some, or any of the CRUD operations.
Getting ready
In this recipe, we will explore a basic way of creating user roles, where an admin user can only perform actions they are entitled to.
Information
Remember that this is just one way of implementing user roles. There are a number of better ways of doing this, but this one appears to be the best one to demonstrate the concept of creating user roles. One such method would be to create user groups and assign roles to the groups, rather than individual users. Another method can be the more complex policy...