How to hide People Who can View option in Page Tools for Anonymous Users and Specific Groups in Confluence?

Still need help?

The Atlassian Community is here for you.

Ask the community

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

  1. Navigate to Confluence Admin >> Custom HTML
  2. Click Edit
  3. 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

  1. Navigate to Confluence Administration page >> Layout.
  2. Under the Site Layouts, search for Main Layout and click Edit/Create Custom.
  3. Find the following section: <head> and </head> tags.
  4. 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

  1. Navigate to Confluence Administration page >> Layout.
  2. Under the Site Layouts, search for Main Layout and click Edit/Create Custom.
  3. Find the following section: <head> and </head> tags.
  4. 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
  5. 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

Collapse

  1. How to hide elements in Confluence using CSS or JavaScript
Last modified on Jul 22, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.