Not signed in (Sign In)

Categories

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthoryutt
    • CommentTimeNov 12th 2007 edited
     # 1
    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.
    • CommentAuthoryutt
    • CommentTimeNov 12th 2007 edited
     # 2
    Okay, I've found how to check a specific permission, but not a role or role ID.

    For others looking for information on this:
    $Context->Session->User->Permission('PERMISSION_NAME_IS_ENTERED_HERE')

    Example:
    <?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. :)
  1.  # 3
    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.
Add your comments
    Username Password
  • Format comments as