Jump to content

Recommended Posts

Posted

Hi,

something I'm not sure about is: How do I define a new user permission? I mean it has to work so I have to place some additional code somewhere, doesn't it?

/ Nico

Posted

A permission is only a name, all the work is done on the access tab of templates, or on the template files:

if($user->hasPermission($permission)) echo $secret_code;
Posted

That's correct, when you add new permissions (via Admin > Access > Permissions) you are adding it for your own use so that you could check if a user has it. You would edit any user roles that you want to have the permission and check the box so they have the permission. Then in your template code, you would check if the current user has that permission via a check like in Diogo's example. You can also just specify the permission name, which is more common to do:

if($user->hasPermission('spam-nico')) {
 for($n=0; $n<999; $n++) mail('hi@nico.is', 'Hi Nico!', 'Would you like some spam?'); 
}
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...