How to hide history from guest users?
Last modified by Oana Florea on 2023/05/10
XWiki provides by default the possibility to hide the page tabs from the Presentation section: Administration Application.
Additionally, with a small development (script/programatic rules) you can display/hide the tabs on specific pages or make them visible only for certain users, see Configuration but they will remain accessible from the URL.
This FAQ will provide an example how to hide a tab like history completely for the guest user (accessing directly http://<server>/xwiki/bin/view/MySpace/?viewer=history will not display the history details):
- Go on the skin http://localhost:8080/xwiki/bin/edit/XWiki/DefaultSkin and override the history.vm template.
- Copy the default content of the history.vm template corresponding to the wiki version you are using.
- Update the content of the macro to include a check to display the history only for Admins, e.g. on 14.10.2:
## ---------------------------------------------------------------------------
## See the NOTICE file distributed with this work for additional
## information regarding copyright ownership.
##
## This is free software; you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as
## published by the Free Software Foundation; either version 2.1 of
## the License, or (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with this software; if not, write to the Free
## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
## 02110-1301 USA, or see the FSF site: http://www.fsf.org.
## ---------------------------------------------------------------------------
###
### History page in the "view" mode
###
###
#set($titleToDisplay = $services.localization.render('core.viewers.history.title', [$escapetool.xml($doc.plainTitle), $doc.getURL()]))
#template('contentheader.vm')
## Custom check: do not display history for guests
#if($hasAdmin)
#template("historyinline.vm")
#end
- Result: accessing http://<server>/xwiki/bin/view/MySpace/?viewer=history does not display the history content.