Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

plugins change Role for Oneload

Good afternoon
I understand a forum and I write a plug-in for dialogue in of Discussion only the owner Discussion and moder/the adviser

I should change a Role for Oneload of the user if it is not the author of Discussion (except for the administrator)

I hope who that already it did.
In advance thanks
__
п.с forgive for bad English__

Comments

  • Sorry, I don't understand. :(

    Do you have already some code that you can show us?
    Or try to make a picture of what should be done?

  • If I understand you correctly, you want to write a plugin that only allows the user who started it and moderators/admins to partake in the discussion.

    Since permissions are additive, I would actually do it the other way around: Remove the Vanilla.Comments.Add permission from your users, but not from the moderators. This will allow you to enforce this on selected categories, if you want.

    Then, your plugin only needs to grant the permission for the user who started the discussion.

    I think what you are looking for is:

    Gdn::Session()->SetPermission('Vanilla.Comments.Add', true);
    
  • to many thanks to for her answer.
    every user must be able to write in own Discussion, however, not in the stranger.
    how I can of Permission' Vanilla. Comments. Of Add' of user take away.
    But only for once Onload(without DB save)

    Thanks

  • You add permissions to roles not users.

    grep is your friend.

  • x00x00 MVP
    edited February 2015

    Changing the permission temporarily is a potentially leaky, and haphazard solution. This breaks the concept of roles/permissions.

    grep is your friend.

  • You can use a custom permission to govern the in context dynamic overriding of the current one.

    However I always see if I can rethink a problem like this. In stead of doing that you also Vanilla.Comments.Add as normally but restrict it further with Vanilla.Comments.AddToOthers, therefore there is no need to override Vanilla.Comments.Add because it would be on, Vanilla.Comments.AddToOthers would restrict if further.

    grep is your friend.

  • thank You .

  • Sorry , this dont work .
    I cann not change temporal Role for User
    cann i my help please? Thank You

  • @gnem40 said:
    Sorry , this dont work .
    I cann not change temporal Role for User
    cann i my help please? Thank You

    I told you that this would not be a good approach.

    grep is your friend.

  • Thank on x00 .

    Its Worked now

    in Config.php

    Junction permission OFF

    $Configuration['Garden']['Permissions']['Disabled']['Category'] = TRUE;
    AND Permission of Group "Vanilla.Comments.Add" = False

    Plugin
    Gdn::Session()->SetPermission('Vanilla.Comments.Add', true);

  • That is one approach, but it is less flexible, obviously you are disabling categories, and it is harder to do mixed functionality.

    However if it suit your purposes,the fine.

    grep is your friend.

  • Hello
    do you got for me a solution as I can then deal 'CheckPermission(...) / array_key_exists ($ permission, $ permissions)', so that I can behlten the Permission 'Category'

    Thank you in advance

Sign In or Register to comment.