Support » Plugins and Hacks » [Plugin: Role Scoper] Tip: Multi-lingual "You are not allowed to view this content" page
4 years, 1 month ago
I’ve been recently involved with a project that required a limited access to certain parts of the WP site. Role Scoper is an excellent plugin but it’s slightly difficult to give a meaningful user experience in cases that user does not have enough privileges to access the requested part.
By default, when unprivileged user requests a page, Role Scoper turns the request to 404 Not Found page (behind the scenes – it seems to deny the WP “core” to find the page).
To give a meaningful message to the user, you have to go to Role Scoper’s Roles -> Options page and find “Hidden Content Teaser” option block. Check the “Enable teaser for Posts, Pages…” checkbox and you are able to see more options. Enable “Fixed teasers” for proper post types.
I created one page (and translated it to all languages) that includes information for user that he needs to log in (or get more privileges from the administrator), with login features embedded. Practically, you can enter anything here.
Finally, I had to get the page contents into Role Scoper’s teasers. There are some plugins that you can use to fetch certain post/page contents, but none of them were WPML-aware – so they returned exactly the language referred by ID.
Fortunately, thanks to good WPML API, it’s simple to create an own shortcode that fetches the given post/page in the current user’s language. You can find & download my shortcode source at https://gist.github.com/3693152 and add it to your theme’s functions.php.
Hope this helps other RS users too. =)