Specific Users Only Include

By James KanjoJames 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 makes this easy.

Syntax

attribute required allowed values default description
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.
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)
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 Extended NewPage Module in “Manual Mode”.


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by James Kanjo


Rate this solution

If you think this solution is useful — rate it up!

rating: +24+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License