Specific Users Only Include

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 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
page 1 of 21
Any code to hide content from non-registered visitors?
Melphyx Melphyx 17 Sep 2019 18:58

I looking for a code hide contents from anonymous visitor or non-registered user. But as well show that content to registered users.

by Melphyx Melphyx , 17 Sep 2019 18:58
When Using suo in Side Bar I Get [div...]
broomhilda broomhilda 02 Oct 2014 20:53

When I use this in the sidebar I get the following displayed in the final rendered page. Any ideas on why this might occur?

[[div class="first showto_%%name%%" style="display: none;"]]

Here is the sidebar code:

+ navigation
* [[[start | Introduction]]]
* [[[contact | Contact Me]]]
* [[[system:list-all-pages | List all pages]]]
* [[[search:site| Search]]]
* [/random Random Page]
[[include :snippets:suo BEGIN CODE |unique=first |type=showto |user=broomhilda]]
+ toolbox
* [[[_admin | Site Manager]]]
* [[[system:recent-changes | Recent changes]]]
* [[[forum:start|Forum]]]
* [[[admin:alerts | Alerts]]]
* [/nav:side/edit/true Edit this menu]
* [[[help | Help with Wiki Syntax]]]
[[module NewPage size="15" button="new page" category="wiki"]]
[[include :snippets:suo END CODE]]
+ tags
[[module TagCloud minFontSize="80%" maxFontSize="200%" maxColor="8,8,64" minColor="100,100,128" target="system:page-tags" limit="30"]]
by broomhilda broomhilda , 02 Oct 2014 20:53
Re: When Using suo in Side Bar I Get [div...]
broomhilda broomhilda 02 Oct 2014 20:57

Of course… as soon as I post this I answer my own question ;-)

Can't include the module NewPage.

NoNo: [[module NewPage size="15" button="new page" category="wiki"]]

Works as expected without this.

Thanks!

by broomhilda broomhilda , 02 Oct 2014 20:57
Enrique Santos Enrique Santos 01 Aug 2014 10:10

SUO snippet generates [[div]] as an intermediate output. That is a problem if you want to put it inside a list (a quite common wanted use) or inline, because Wikidot converts a [[div]] into:

<div><p>...</p></div>

Would it be possible to modify the snippet to use [[span]] instead of [[div]]?. Wich are the drawbacks of it?. See Problems with Divs.

by Enrique Santos Enrique Santos , 01 Aug 2014 10:10
Forums?
lacyjae lacyjae 27 Aug 2011 16:30

Stumbled across this looking for a way to hide/block users from certain forums but I'm pretty new to wikidot and I'm not sure if it can work that way. Any thoughts or suggestions?

by lacyjae lacyjae , 27 Aug 2011 16:30
Uberman Uberman 21 Jul 2011 01:38

Shucks, just when I thought I had a convenient scapegoat on which to blame all of my problems.

Thanks for the info.

by Uberman Uberman , 21 Jul 2011 01:38
Module Troubles
Uberman Uberman 13 Jul 2011 09:46

Hey James,

Firstly thanks for this cracking snippet, it's really right up my street, but alas I've encountered a problem:

I've got several instances of this snippet at the top of the sidebar on my site all in default mode and all working perfectly. However, further down my sidebar I have a separate listpages module and several instances of the countpages module.

Now, despite my SUO snippets using only the listusers syntax (indeed, I've manually specified default mode for each of them), they stop both the listpages and countpages modules from updating for varying lengths of time (an hour to over a day's worth). The information they show remains the same even after I make new pages that should show up on or affect the data those modules display.

I tried removing it quickly to double check it was definitely the problem, and both sets of modules instantly updated themselves…

Having checked the "Important" segment of the documentation numerous times there seems to be no mention of such occurrences in default mode and nothing at all for the countpages module.

[[include :snippets:suo BEGIN CODE |unique=administrators |type=showto |mode=default |user1=uberman]]
++++ Hey, [http://ddl-anime.wikidot.com/profile:%%number%% %%title%%]!
[[size 80%]]Wikidot ID: %%number%%
Role: Admin
[http://ddl-anime.wikidot.com/mod:new-page New Page]
[http://ddl-anime.wikidot.com/sandbox Sandbox]
[http://ddl-anime.wikidot.com/mod:mod-cp Moderator CP]
[http://ddl-anime.wikidot.com/admin:manage Admin CP]
= [[button Edit]] [[button Tags]] [[button Rename]] [[button Source]][[/size]]
[[include :snippets:suo END CODE]]
[[include :snippets:suo BEGIN CODE |unique=managers|type=showto |mode=default |user1=psychia
++++ Hey, [http://ddl-anime.wikidot.com/profile:%%number%% %%title%%]!
[[size 80%]]Wikidot ID: %%number%%
Role: Manager
[http://ddl-anime.wikidot.com/mod:new-page New Page]
[http://ddl-anime.wikidot.com/sandbox Sandbox]
http://ddl-anime.wikidot.com/mod:mod-cp Moderator CP]
= [[button Edit]] [[button Tags]] [[button Rename]] [[button Source]][[/size]]
[[include :snippets:suo END CODE]]
[[include :snippets:suo BEGIN CODE |unique=staff |type=showto |mode=default |user1=xalathal |user2=bolei-cha |user3=daudemex]]
++++ Hey, [http://ddl-anime.wikidot.com/profile:%%number%% %%title%%]!
[[size 80%]]Wikidot ID: %%number%%
Role: Staff
[http://ddl-anime.wikidot.com/mod:new-page New Page]
[http://ddl-anime.wikidot.com/sandbox Sandbox]
[http://ddl-anime.wikidot.com/mod:mod-cp Moderator CP]
= [[button Edit]] [[button Tags]] [[button Rename]] [[button Source]][[/size]]
[[include :snippets:suo END CODE]]
[[include :snippets:suo BEGIN CODE |unique=members |type=hidefrom |mode=default |user1=uberman |user2=psychia |user3=xalathal |user4=bolei-cha |user5=daudemex]]
++++ Hey, [http://ddl-anime.wikidot.com/profile:%%number%% %%title%%]!
= [[size 80%]]//[http://ddl-anime.wikidot.com/profile:%%number%%/edit/true click here to edit your profile]//[[/size]]
[[include :snippets:suo END CODE]]
------
++++ Latest Added Series
[[module ListPages separate="yes" limit="10" tags="anime" category="*, -template"]]
%%title_linked%%
[[/module]]
[[table style="margin: 0 5px;"]]
[[row]]
[[cell style="padding: 6px; background-color: #FFFFFF; border: 1px solid white; width: 100%;"]]
[[/cell]]
[[/row]]
[[/table]]
[[image http://ddl-anime.wikidot.com/local--files/nav:side/963eca7d69d5b41af39f15e35862ed0b.png alt="Peekaboo!" link="random" width="100%"]]
[[table style="margin: 0 5px;"]]
[[row]]
[[cell style="padding: 6px; background-color: #FFFFFF; border: 1px solid white; width: 100%;"]]
[[/cell]]
[[/row]]
[[/table]]
------
[[module CountPages category="*, -template" tags="anime" pagetype="*"]]
++++ DDL-Anime Stats
DDL-Anime has **%%total%%** anime series of which:
[[/module]]
[[module CountPages category="*, -template" tags="anime,-hentai,-redirect" pagetype="*"]]
• **[http://ddl-anime.wikidot.com/full-list %%total%%]** are anime
[[/module]]
[[module CountPages category="*, -template" tags="hentai,-redirect" pagetype="*"]]
• **[http://ddl-anime.wikidot.com/system:page-tags/tag/hentai %%total%%]** are hentai
[[/module]]
[[module CountPages category="*, -template" tags="redirect" pagetype="*"]]
• **[http://ddl-anime.wikidot.com/system:page-tags/tag/redirect %%total%%]** have alternative titles
[[/module]]
[[module CountPages category="*, -template" tags="dualaudio,-redirect" pagetype="*"]]
• **[http://ddl-anime.wikidot.com/system:page-tags/tag/dualaudio %%total%%]** are dual audio
[[/module]]
[[module CountPages category="*, -template" tags="mature,-redirect" pagetype="*"]]
• **[http://ddl-anime.wikidot.com/system:page-tags/tag/mature %%total%%]** are mature
[[/module]]
[[module CountPages category="*, -template" tags="720p,1080p,1440*1080,1440*768,1824*992,-redirect" pagetype="*"]]
• **[http://ddl-anime.wikidot.com/system:page-tags/tag/720p %%total%%]** are 720p HD or higher
[[/module]]
Last edited on 13 Jul 2011 09:52 by Uberman
by Uberman Uberman , 13 Jul 2011 09:46
Re: Module Troubles
GoVegan GoVegan 13 Jul 2011 14:06

I've checked your code, and there's nothing wrong with it.

It sounds like a Wikidot caching issue… Let me ask, is the updating issue with the CountPages module only, by any chance?

by GoVegan GoVegan , 13 Jul 2011 14:06
Re: Module Troubles
Uberman Uberman 13 Jul 2011 14:13

Well, that's what I thought too, it just seemed like a fantastic coincidence for it to suddenly change when I removed the code and checked.

Edit: Especially since I've always kept a close eye on the goings on of the sidebar and I've never had this problem until I started using the SUO snippet.

Both the ListPages and CountPages modules fail to update.

Last edited on 13 Jul 2011 14:17 by Uberman
by Uberman Uberman , 13 Jul 2011 14:13
Re: Module Troubles
GoVegan GoVegan 13 Jul 2011 22:28

Hmm, odd. I've created a bug report, hopefully something should get resolved soon.

by GoVegan GoVegan , 13 Jul 2011 22:28
Re: Module Troubles
Uberman Uberman 20 Jul 2011 23:23

Sadly the problem has progressed further:

Now occasionally when I save a page after editing it, it'll revert back to a previous iteration/save of the page.

In my case, I have two page layouts, an old one and a new one. After updating a page from the old layout to the new one and hitting save there's a good chance it'll show the old layout prior to my editing it (which is remarkably different to the new one, there's no mixing them up). I have to refresh the page once or twice to get it to behave.

To further compound the issue, when I start editing pages after refreshing them in such a manner they occasionally show the wiki code from a previous iteration using the old layout, despite me having completely rewritten it since. This happens regardless of whether the old layout or the new layout is showing.

*Pulls out hair*

Edit: It goes without saying that neither of these problems happened even once prior to the implementation of this code, not in over 2.5 years.

Last edited on 20 Jul 2011 23:25 by Uberman
by Uberman Uberman , 20 Jul 2011 23:23
Re: Module Troubles
leiger leiger 21 Jul 2011 00:35

I've heard of similar things happening to other users before (and I think it may have happened to me as well). It's a Wikidot bug.

If you post what you just told us on http://feedback.wikidot.com as a bug report, they should be able to fix it.


~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

by leiger leiger , 21 Jul 2011 00:35
Form Data Inside SUO
(account deleted) 27 May 2011 15:32

I am using SUO in a live template to selectively display an email address field to only site admins and moderators. The problem is that I can't get the form data to display the contents of the field - it just displays the variable. Is this a bug or a limitation of using form data with SUO?

This code works in the live template when it's outside of the SUO snippet, but doesn't when it's inside the SUO wrapper.

User's email address: %%form_data{email}%%

Here's the source of the page:

[[include :snippets:tweet-button
|url=%%link%%
|text=I'm browsing: %%title%%
|via=eagletracegolf
|count=horizontal
|align=right
]]
[[div class="myblockquote" style="margin-left: 50px;"]]
Submitted by: [[size 120%]]%%form_data{name}%%[[/size]] on %%created_at|%B %d, %Y|agohover%%
%%form_data{summary}%%
%%form_data{readmore}%%
[[/div]]
[[include :snippets:suo BEGIN CODE |unique=announce|type=showto
|user1=ed-johnson
|user2=steve-johnson
|user3=joel-vogel
|user4=nancy-gohman
|user5=robelliott
]]
----
User's email address: %%form_data{email}%%
----
[[iftags +_active]]
This testimonial is currently **active**.
[[button edit text="Edit this testimonial" class="tag-buttons"]][[button set-tags -_active text="Make INACTIVE" class="tag-buttons"]]
[[/iftags]]
[[iftags -_active]]
This testimonial is currently **inactive**.
[[button edit text="Edit this testimonial" class="tag-buttons"]][[button set-tags +_active text="Make ACTIVE" class="tag-buttons"]]
[[/iftags]]
[[include :snippets:suo END CODE]]
~~~~
[!--
 email:
 label: Your email address
 type: text
 width: 50
 match: /^$|^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/
[[module Comments]]
--]
====
[[form]]
fields:
 header:
 type: static
 value: Thanks For Telling Us Your Story
 intro:
 type: static
 value: Please fill out this form and save it. After saving, we will review the story before making it public. //We reserve the right to edit stories and control whether it's made visible to the public or not.//
 join: true
 name:
 label: Your first name
 type: text
 default: Your first name
 width: 30
 join: true
 email:
 label: Your email address
 type: text
 width: 50
 hint: Optional, won't be displayed. Enter it if you'd like a response.
 match: /^$|^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/
 join: true
 summary:
 label: Summary
 type: wiki
 width: 80
 height: 3
 default: This is the text displayed on the main index page before the "read more..." link.
 join: true
 readmore:
 label: The rest of your story
 type: wiki
 width: 80
 height: 5
 default: Fill in the rest of your story here.
 join: true
[[/form]]
Last edited on 27 May 2011 15:35 by (account deleted)
by (account deleted), 27 May 2011 15:32
Re: Form Data Inside SUO
leiger leiger 27 May 2011 16:41

Unfortunately, that's a limitation. The SUO module is based on the ListUsers module, which only allows the following:

  • title
  • name
  • number

Other variables are ignored.

It's just like other modules (think of ListPages within a live template) - you can use variables as part of the module's parameters (e.g. perPage="%%form_raw{field}%%" should work), but if you try to put it inside the module body it becomes out of scope of the live template - it's in scope of the ListPages module instead.

As far as I understand, the same thing is happening here… the variable is in scope of the SUO (ListUsers) module, not the live template.


~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

by leiger leiger , 27 May 2011 16:41
GoVegan GoVegan 22 May 2011 05:45

At the time of this post (405 days after the birth of SUO), there are 216 pages on Wikidot using this technology!

Last edited on 22 May 2011 05:48 by GoVegan
by GoVegan GoVegan , 22 May 2011 05:45
leiger leiger 22 May 2011 07:17

Is that all?

We need to spread the word!

There are currently 8,893,011 pages at Wikidot. SUO deserves to be on at least half of those… surely! XD


~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

by leiger leiger , 22 May 2011 07:17
GoVegan GoVegan 22 May 2011 07:29

I know! Apparently people would rather have MP3 Players on their sites than to show things to specific users… what's going on?!

Actually, something made my day the other day — the Wikidot team are using SUO in the feedback site! I'm so happy!

by GoVegan GoVegan , 22 May 2011 07:29
Thought I'd Just Add
Deonte Deonte 24 Apr 2011 09:38

With the new fix, you can just type %%created_by_unix%% for in code use

by Deonte Deonte , 24 Apr 2011 09:38
"type" is required, isn't it?
GoVegan GoVegan 30 May 2010 05:31

Yes, I'm stupid =D

by GoVegan GoVegan , 30 May 2010 05:31
Re: "type" is required, isn't it?
leiger leiger 30 May 2010 05:37

Your words, not mine :)


~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

by leiger leiger , 30 May 2010 05:37
page 1 of 21
page revision: 17, last edited: 24 Jul 2013 06:16
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 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).

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