Check content permissions in code (custom template)
-
Hello!
I am using this plugin to restrict users from accesing certain pages of the website unless they are asigned a specific role. That means that on page with ID XX in a “Content Permission” box, under “Limit access to the content to users of the selected roles” I have selected only a few roles that can access the content.
What concerns the main content it works as expected out of the box – if user is not assigned a role that has had access granted, custom error message is shown. However, I have a section on some pages showing related content (on the same website). I need to create a custom logic that would check for a current user whether he/she is allowed to access that content/page. If yes, than the link to this page will be shown, otherwise not.
So, the question is, how to check in code if current user is allowed to access a page/post with ID XX or not?
Thanks in advance!
- You must be logged in to reply to this topic.