Show page to specific users only

Posted by Helmut_pdorf on 12 Dec 2010 15:57, last edited by RobElliott on 11 Sep 2011 09:46

: howto specific_user_only suo

rating: +1
Notice: this is in most sequences a copy of the used snippets code Specific Users Only Include (SUO) implemented by James Kanjo James Kanjo .

Description

A common request amongst Wikidot users is the ability to show or hide data based on the person who is viewing your wiki. For example, if a wiki administrator is viewing the wiki, then s/he should be able to see options such as "Manage Site", "Edit Side Bar" and "Change CSS". Perhaps you have decided that particular members of a wiki should not see certain options in the sidebar, such as welcome links for new visitors on a site.

The Specific Users Only Include ( SUO) makes this easy.

Syntax

attribute required allowed values default description
unique no alphanumeric characters, hyphens and underscores universal For the use of multiple SUO Includes on a single page (each one will need a unique identifier)
type yes showto or hidefrom none (it must be manually entered) This specifies the type of SUO Include you wish to use. You can show data to the specified users, or you can hide data from specific users.
user no A Wikidot user's UNIX name none This means lowercase letters, with spaces separated by hyphens. You can find this by clicking on a user's avatar, and taking note of their "profile page" link.
user0 Same as above, but for when applying SUO data to multiple users
user1
user99 Currently supports up to 101 users
mode no default or advanced default For using advanced variables, such as %%created_by%%, as a user

The syntax is to use the SUO include with its attributes, followed by your Wikidot code on a new line, then by the SUO include again (but with NO attributes).

Code

[[include :snippets:suo BEGIN CODE |unique=first |type=showto |user1=james-kanjo |user2=michal-frackowiak]]
**Hello James Kanjo & Michał Frąckowiak!!!**
[[include :snippets:suo END CODE]]

[[include :snippets:suo BEGIN CODE |unique=second |type=hidefrom |user1=james-kanjo |user2=michal-frackowiak]]
**Hello Everybody Else!!!**
[[include :snippets:suo END CODE]]

In action

Important

Because the framework of this include is based upon the ListUsers Module, certain limitations apply:

  • The use of Modules inside the SUO code is prohibited
  • Anonymous Users will see nothing, because the ListUsers Module doesn't display data to anonymous users
  • When in "Advanced Mode", as the advanced mode utilises the ListPages Module, it cannot be nested inside the ListPages module (and cannot be included by a ListPages module)

In terms of having a NewPage module as part of your SUO code, a working alternative is the code:newpage in "Manual Mode".

Notice: The usage of live - "_template"s to hold such SUO codes for a complete category is not working - the "%%content%%" variable is not replace by the content anyway!

Important 2

This technique used and generated by the SUO code does NOT MAKE THE TEXT SECURE! If you click with right mouse and select "show source" - than you will see the resulting "div" sections WITH the tet not show to other users:
(in my case with MY "User-id" - if you have a look on the source text of the html-rendered output you will see here YOUR userid).

<divclass="first showto_helmuti-pdorf"style="display: none;"><p><strong>Hello James Kanjo &amp; Michał Frąckowiak!!!</strong></p></div><divclass="second hidefrom_helmuti-pdorf"style="null"><p><strong>Hello Everybody Else!!!</strong></p></div>

Notice: the created class "first showto_….." joined with the actual Userid and with the used style="display: none;"
( otherway round - the class "second hidefrom_…." style="null" makes this viewable..)

Usage

Imagine you try to create for a class different "private" pages for every student ( and of course the admin-teacher) - this can not be done with "private" categories, but with the usage of the "Listuser-Module" and the iftags

1. You need only at the start of such a page a little "include" of the "BEGIN Code" of such SUO - defining the users who are allowed to see the rendered content ( or not).
2. At the end of the "private content" there have to be the END-code to end the starting conditions.

3. You need to disallow the page edit options for the sued category - because any other reader can see the source code if s/(he is allowed to do so.

4. You need to insert the eliminated "page options buttons" as stand alone buttons inside the viewable content - to give the allowed persons the ability to edit (and view) the source code.


Related articles

Comments

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).
Notify administrators if there is objectionable content in this page.
Something does not work as expected? Find out what you can do.
General Wikidot.com documentation and help section.
Wikidot.com Terms of Service - what you can, what you should not etc.
Wikidot.com Privacy Policy.

AltStyle によって変換されたページ (->オリジナル) /