The {hide-from} macro hides page content from specific users or groups...
There may be times when you want to hide content on Pages, [USERGUIDE:News], [USERGUIDE:Comments], the Site Welcome Message and even [user profiles] from particular users or groups of users and that's what the {hide-from} macro is designed to do.
Such a feature allows you to, for example, display a message asking the user to login if they are not currently logged in.
The {hide-from} macro hides it's contents based on various settings:
{hide-from:user=users|group=groups|space=spaces|trim=true/false|match=all/any}Any content to be
hidden{hide-from}
Parameters
Parameter
Required
Notes
user
A list of one or more users to hide the content from.
group
A list of one or more user groups to hide the content from.
space
If the user has the specified privileges within the spaces listed, the content will be hidden.
To add a privilege to a specific space, use "SpaceKey:Privilege". Valid privileges are:
Privilege
Notes
view
The user can view the space (default).
edit
The user can edit the space.
admin
The user can administrate the space.
news
The user can add news to the space.
match
By default, if any of the criteria match the logged in user, the content will be hidden. However, if you set this parameter to all then every single criteria will have to match before the content can be hidden.
This macro should only be used as a simple way to personalise content depending on the logged in user and optionally any space-specific privileges they may have.
This macro should not be used as a security mechanism. While it will hide the content in most circumstances, the content will still be indexed by the search engine and features such as [USERGUIDE:Page Source] will still display the content.
Do not use this macro to hide confidential or sensitive information because the content will still be visible via some views or features of the software.
This plug-in is available without cost for both commercial and non-commercial purposes. However, if you have found it to be useful, particularly within a commercial environment, please consider making a donation to the author. This will encourage continued development of this and other plug-ins, as well as speeding up the response for your latest maintenance request.
If you wish to donate, it can be done easily with a credit card or bank transfer using Paymate. No account sign-up is required for credit card payments.
This macro is compatible with Confluence 1.3.x and 1.4.x. It has been tested by Adaptavist with Confluence 1.4.1 and 1.4.3.
This macro is usually pre-installed with Builder accounts. If you wish to install it on your own Confluence install, please download it from the Confluence Extensions page.
Adaptavist maintain a JIRA Project for tracking bug reports and feature requests for this macro. The currently reported items are shown below:
jiraissues: Could not download[ http://jira.adaptavist.com/secure/IssueNavigator.jspa?view=rss&pid=10030&component=10084&statusIds=1&statusIds=3&statusIds=4&statusIds=5&sorter/field=priority&sorter/order=DESC&tempMax=25&reset=true&decorator=none] : caused by : Circular redirect to 'http://jira.adaptavist.com:80/secure/IssueNavigator.jspa'
All registered users are automatically added to the confluence-users[user group] so as soon as they log in, they are seen as being a member of that group. This provides the perfect mechanism for displaying content to anonymous users by simply hiding it from logged in users:
{hide-from:group=confluence-users}*You are not logged in - Please {link-to:login}click here
to login{link-to}.*{hide-from}
An anonymous user (which includes a registered user that hasn't logged in yet) would see this:
Whereas users who are already logged in would see nothing.
Hiding from specific users
You can hide content from one or more specific users by adding their user names:
{hide-from:user=bob,fred}*Shh! Bob and Fred can't see this!*{hide-from}
Everyone except Bob and Fred would see the content:
Shh! Bob and Fred can't see this!
Bob and Fred would not be able to see the message if they were logged in. However, if they were not logged in the software would not know that they were Bob or Fred and they'd see the message.
To overcome that, you could also include the show-to macro as follows:
{show-to:group=confluence-users}{hide-from:user=bob,fred}*Shh! Bob and Fred can't see
this!*{hide-from}{show-to}
By doing this, you only show the content to logged in users but hide it if the logged in user is Bob or Fred.
Hiding from users depending on their Space privileges
If you have content that refers to specific Spaces, or operations that need to be performed within those spaces, there's no point in displaying that content to users who cannot view those spaces or perform those tasks:
{hide-from:space=Intranet}*You do not have access to the Intranet.*{hide-from}
If the logged in user can view the Intranet space, they will not see the message.
{hide-from:space=Intranet:edit}*You can view, but not edit the Intranet.*{hide-from}
Anyone who has View access to the Intranet space, but does not have edit permissions would see the message:
You can view, but not edit the Intranet.
However, anyone who has edit permissions on that space would not see the message.
Hiding only if all criteria match
Normally the content will be hidden if any of the criteria match, however you can force the macro to only hide content if all criteria match:
{hide-from:group=staff|space=Intranet|match=all}*Content to hide.*{hide-from}
The above would hide the content only if the logged in user was a member of the staff group and has view access to the Intranet space.
{hide-from:group=staff,managers|match=all}*Content to hide.*{hide-from}
The above would hide the content only if the logged in user was both a member of the staff group and also the managers group.
Hints and Tips
When hiding content, remember that logged out users will be not be recognised (either by user name, group or space privileges) so you should consider using the show-to macro in addition to {hide-from} as seen in our example earlier on this page.
You could create an "advanced-users" group in order to hide verbose instructions from users in that group.
Frequently Asked Questions
Q
Rather than hiding content from specific users, etc., I want to show it to them - how?