Giving only certain users access to a category using the API V2
Hello
I am trying to use the V2 api to make a category available only to certain users of the forum.
For this I think I have to create a role, add the users I want to view that category to that role, and set the read/write permissions on that role for that category.
Does anyone have an example on how to do this using the API?
Does anyone know another way to do this that can also be done using the API?
The problem is that the documentation doesn't have any example for this and is not very clear on how to do this.
In https://docs.vanillaforums.com/apiv2/swagger/#/Roles/patch_roles__id_ there is a permissions array, but I'm not sure what it should contain.
From the Model I understand it's a PermissionFragment that has
id
type
and
permissions* {
}
But again it's not very specific regarding the permissions format.
https://docs.vanillaforums.com/apiv2/swagger/#/Roles/patch_roles__id__permissions has even less information.
I noticed the v1 api you could set permissions directly for a category https://docs.vanillaforums.com/api/categories/ but I want to host the forum myself and v1 is only for the hosted solution.
I also you can set a group for a category, but I couldn't find any group functionality like describe in the documentation so I'm guessing it's a hosted only plugin.
Comments
Hi, I have the same problem. how can i solve this? do someone know the structure of permissions? I think that the API isn't finished.
Thanks
The API doesn't allow 100% of the actions that the forum offers by now, that's correct. But that use case should be possible.
You certainly have to know how to do things in Vanilla before you can use the API. That means, if you want "only some users having access to a category", you need to also change the category: https://docs.vanillaforums.com/help/apiv2/swagger/#/Categories/patch_categories__id_
Thanks you for you answer. I was trying the same but the step 2 doesn't have the permissions structure. do you have this structure? In the body only says: [null]
I solved the problem. I used the follow structured. Maybe a someone could help:
[
{
"id": 2,
"type": "category",
"permissions": {
"comments.add": false,
"comments.delete": false,
"comments.edit": false,
"discussions.add": false,
"discussions.manage": false,
"discussions.moderate": false,
"discussions.view": true
}
}
]
This is for API2 roles/id/permissions