I am building a site where users are given permissions similar to SO. I am working with two models.

The first model assigns roles to users based on points. I can probably use Rules or a build a module for that. The nice things with this is that I get to use Drupal's build permission system. The downside is that I probably have to setup +10 roles and add even more if I want to give new permissions.

The second model is based on a custom build module (not build) that checks if a user is permitted to do whatever he/she intends to do. In this way all the roles can be avoided, but it doesn't use Drupal's permission system, which makes me a bit uncomfortable. On the other hand, there is no need for many roles.

So, is there a performance hit on having many roles? Other problems?

Any thought on this? Other approaches to give users permissions based on user points?


Use roles.

The only problem with 10+ roles is that your permission table is going to get huge but you can solve this by limiting it per role (see link on roles list) or use a module like faster permissions.

The loading of roles is most likely much faster than doing custom checks. Also, when doing something like this, you'll certainly run into issues, for example when trying to work around existing permission checks in modules and so on. The permission system is one of the core elements of Drupal. Use it and don't try to fight it. That's not going to work.

There is a Userpoints Role module in http://drupal.org/project/userpoints_contrib, which allows you to configure how many points users require for a given role and it should just work. There are even a few tests there now. Note that it currently gives you all permissions the user has enough points for. This might not be what you'd expect but it has the advantage that it would be enough to only specify the additional permissions each role has.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.