Role Scoper
Tip: Multi-lingual "You are not allowed to view this content" page (1 post)

  1. Ville Mattila
    Posted 2 years 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. =)



Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Role Scoper
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by Ville Mattila
  • This topic is not a support question
  • WordPress version: 3.4.2