Creating user roles
Until now, we saw 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 see a basic way of creating user roles, where an admin user can only perform actions they are entitled to.
Note
Remember that this is just one way of implementing user roles. There are many better ways of doing this, but this one seems to be the best one to demonstrate ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access