CSV Export of Users

Last modified by Pascal Bastien on 2021/03/18 11:28

cogExports users of the wiki in CSV format
TypeSnippet
Category
Developed by

Thibaut Camberlin

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

Copy / paste this code in a page and you'll be able to download the users of your wiki in CSV format

{{velocity}}
#if("$!{request.confirm}" == '1')
  #set($ok = $response.setContentType("text/csv"))
  #set($ok = $response.setHeader("Content-disposition", "attachment; filename=export-users.csv"))
login;firstname;lasname;email;phone
  #set ($sql = ", BaseObject as obj where obj.name = doc.fullName and obj.className = 'XWiki.XWikiUsers' and obj.name <> 'XWiki.XWikiUserTemplate' order by doc.name asc")
  #foreach($user in $xwiki.searchDocuments($sql))
    #set($userDoc = $xwiki.getDocument($user))
"$userDoc.name";"$userDoc.get('first_name')";"$userDoc.get('last_name')";"$userDoc.getValue('email')";"$userDoc.get('phone')"
  #end
#else
 * [[Download CSV list of users>>?confirm=1&xpage=plain&outputSyntax=plain]]
 * [[Download CSV list of users (link if xwiki 2.1 syntax)>>||queryString="confirm=1&xpage=plain&outputSyntax=plain"]]
#end
{{/velocity}}
     

Get Connected