In the community that I'm working on we have some categories that are restricted to some users. How can I display custom message for this users when they enter a restricted category?
something like "Sorry, this si a close community. If you would like to ask for access please contact us at... "
You can do it using customisation. The message can be shown if the user has that particular role after that we can redirect to the last visited page.
1. Write a code to check if the user has that specific role. If no, just show the pop-up and redirect the user to the last visited page or homepage.
2. Add the code in the header so it would work for the deep link as well(also wrap this function in condition so it can work on that restricted category only).
In our community, we edited one of the default error messages to display the message we wanted -- rather than using a customization.
Here are the text keys we used:
The message displays when a user attempts to access a node or piece of content that they don't have permission for.
You need to build a custom component (Tutorial on building a custom component: https://community.lithium.com/t5/Developer-Knowledge-Base/Component-tutorial-Building-your-first-cus... ) which checks for the presence of the necessary permissions to access a node (See https://community.lithium.com/t5/Developer-Discussion/Check-specific-permission-of-a-role/m-p/385781... If the current user doesn't have the permission you will output a helpful message (Using the "text" context object to output a string: https://freemarker-docs-portal.lithium.com/refer/contextObjects#text ) instructing them how to request the role.
Finally you add this custom component to the page layout for the UserLoginPage which is where visitors without the necessary permissions to access a node will get redirected. See the advance studio course on layouts here: https://community.lithium.com/t5/Developer-Knowledge-Base/Advance-Studio-Documentation-Part-1-Layout...