Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How do I check user permissions?

edited November 2007 in Vanilla 1.0 Help
I'm looking to display information based on the user's permissions, for example something like:

if ($Context->User->Role == "admin") { echo "Fancy admin things!"; } else { echo "Lame user things. :("; }
I have been looking, but unable to find the class/function to check a user's role or permissions, or what the proper syntax is.


  • Options
    edited November 2007
    Okay, I've found how to check a specific permission, but not a role or role ID.

    For others looking for information on this:

    <?php include("./appg/settings.php"); include("./appg/init_people.php"); if ($Context->Session->User->Permission('I_CAN_HAS_CHEEZBURGER')){ echo "u can has cheezburger"; } else { echo "You cannot have a cheeseburger."; } ?>

    Now, I'd like to learn how to add a custom permission. :)
  • Options
    It would seem there's an AddPermission function in the core but I'm not 100% on how it works. In my ReportPost extension I use: $Context->Configuration['PERMISSION_RECIEVE_POST_REPORT'] = '0'; to add a permission and the method you found to check for it. I dunno if the AddPermission function is a more up to date way of doing this or what but I'd use the line above for simplicity.
This discussion has been closed.