How to hide People Who can View option in Page Tools for Anonymous Users and Specific Groups in Confluence?
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The People who can view allows users to see the list of users who can view the Page. If you need to hide this menu option from Page tools for anonymous users or specific groups, you may do so by using JavaScript.
Solution
How to hide People who can view for Anonymous users
Navigate to Confluence Admin >> Custom HTML
Click Edit
Add the following to At the end of the HEAD section and click Save:. Once this is done, People who can view will be hidden for anonymous users.
1 2 3 4 5 6 7 8
<script type="text/javascript"> AJS.toInit(function(){ if (AJS.params.remoteUser == ''){ AJS.$('#who-can-view-button-ak-button').hide(); } }); </script>
How to hide People who can view option for users that are not members of confluence-admin group
Navigate to Confluence Administration page >> Layout.
Under the Site Layouts, search for Main Layout and click Edit/Create Custom.
Find the following section:
<head>
and</head>
tags.Copy and paste the following code before the
</head>
tag.1 2 3 4 5 6 7 8
#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name)) #else <script type="text/javascript"> AJS.toInit(function(){ AJS.$('#who-can-view-button-ak-button').hide(); }); </script> #end
How to hide People who can view option for users that are members of specific groups
Navigate to Confluence Administration page >> Layout.
Under the Site Layouts, search for Main Layout and click Edit/Create Custom.
Find the following section:
<head>
and</head>
tags.Copy and paste the following code before the
</head>
tag.1 2 3 4 5 6 7 8 9 10 11 12 13
#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name) || $userAccessor.hasMembership('confluence-users', $helper.action.remoteUser.name) ) <script type="text/javascript"> AJS.toInit(function(){ AJS.$('#who-can-view-button-ak-button').show(); }); </script> #else <script type="text/javascript"> AJS.toInit(function(){ AJS.$('#who-can-view-button-ak-button').hide(); }); </script> #end
Replace the groups confluence-administrators and confluence-users with your required groups. Once saved, users of only these groups will be able to see the People who can view option.
Related Content
Was this helpful?