How to restrict access to categories based on outside privileges?
-
Let's say you have your own site and member database, with its own gated access to content, and you want to mimic this sort of arrangement with your forum.
e.g. On
member site
, you have free users and paid users, and you want to only allow access to a couple super special categories oncommunity site
to paid users, while free users get the regular set of categories.The good news is, the Session Sharing plugin has had support for this since 2018!
You'll want to enable the options in the session sharing plugin:
- You can opt to only add users to groups, only remove users from groups, or both.
- You can also specify which groups that the automatic group syncing applies to
Once enabled, you need only update your shared cookie to contain a
groups
property, which is of type Array. This array contains the group names in NodeBB that the user should be a part of.If group leaving is enabled, then the user will be removed from any groups that are not in this array, upon login/revalidation.
Once you have your group memberships sorted out, you'll want to restrict access to specific categories based on user group membership.
You can do that from the ACP > Manage > Privileges page. Simply remove access for the
registered-users
groups from your choice of categories, and grant those viewing/posting privileges to the paid users group.