Nico Knoll Posted November 11, 2012 Share Posted November 11, 2012 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 Link to comment Share on other sites More sharing options...
diogo Posted November 11, 2012 Share Posted November 11, 2012 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; Link to comment Share on other sites More sharing options...
ryan Posted November 12, 2012 Share Posted November 12, 2012 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?'); } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now