How to hide More Actions menu?
Version 1.1 by Camelia Andrei on 2020/04/24
How to hide More Actions menu for non-Admin users:
Customize your skin
Use Skin application to customize your skin.
Adding an overridden template object
- Go to the Administration, in the "Look & Feel" section
- Enter the name of the skin to edit (by default: XWiki.DefaultSkin).
- Click on "Customize".
- You will get the skin edition page
- Go to the "Overridden templates" section:
- Enter the name of the template that you want to override. In this case layoutExtraVars.vm
By overriding this .vm file you can custom skins safely override layout variables that are in layoutvars.vm .
Other templates that can be overridden e.g.: view.vm, footer.vm, style.css, etc...
- You need add your restrictions:## Hide More Action Menu if the user not an admin
#set($currentUserGroups = $services.user.group.getGroups($xcontext.user, 'xwiki', $true))
#set($userGroupReference = $services.model.createDocumentReference('xwiki', ['XWiki'], 'XWikiAdminGroup'))
#if (!($currentUserGroups.contains($userGroupReference) || $hasAdmin))
#set($displayMoreActionsMenu = false) ## more actions menu
#set($displayAdminMenu = false) ## the admin menu, related to the page
#end
Also you may find helpful details on this Skin tutorial.
Note that there's a small bug present XWiki versions older than 11.10.5 or 12.3-rc-1.
Create Skin extension
Add StyleSheet extension object
- Create a page, e.g. MyCode.MoreActionsMenuCustomization.
- And edit the page with the Object editor. The page itself can be any XWiki page - an existing page or a new page.
- From the New Object drop-down list of the object editor choose XWiki.StyleSheetExtension. Then, click the "Add" button. We will name it Hide More Action Menu, give it a default cache policy, ask it to parse the content, and write the following code:## Hide tabs if the user is not internal or not an admin
#set($currentUserGroups = $services.user.group.getGroups($xcontext.user, 'xwiki', $true))
#set($internalUserGroupReference = $services.model.createDocumentReference('xwiki', ['XWiki'], 'XWikiAdminGroup'))
#if (!($currentUserGroups.contains($internalUserGroupReference) || $hasAdmin))
#tmMoreActions {
display: none;
}
#endYou can ask to have it used "Always on this wiki". For this to happen however, you need to save the extension document with programming rights.
- Just click "Save and View" .
Lean more about Skin Extension: Skin Extensions Tutorial