How to hide People Who can View option in Page Tools for Anonymous Users and Specific Groups in Confluence?
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Purpose
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.
<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.#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.#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.