HowCanIMakeContentAppearOnlyForASpecificGroup

Last modified by Vincent Massol on 2026/11/13 21:59

Question How can I make content appear only for a specific group?
Answer

In syntax 2.0:

{{velocity}}
#if($services.user.group.isMember($xcontext.userReference, $services.model.resolveDocument('XWiki.PrivateGroup')))
Put the private content here.
#end
{{/velocity}}

In syntax 1.0:

#if($services.user.group.isMember($xcontext.userReference, $services.model.resolveDocument('XWiki.PrivateGroup')))
Put the private content here.
#end

This also takes into account the members of the sub-groups of the group. On XWiki versions older than 18.10, which don't have this API, use the following condition instead, which only takes into account the direct members of the group:

$xwiki.getUser().isUserInGroup('XWiki.PrivateGroup')

Get Connected