Change creator, author or contentAuthor

Last modified by Eduard Moraru on 2022/02/28 00:24

user_goChange the creator, last author or content author fields for a specified existing document with a specified user.
Developed by

Eduard Moraru

Active Installs38
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager


Changes the creator, last author or content author fields for a specified existing document with a specified user.

This is useful, for example, when the creator of a document is important and, even if you have created a document, you want to give credits to someone else.

Another important usecase of this is when you want to assign Script Rights or Programming Rights to a page (by setting the contentAuthor). This is similar to the Change Content Author extension in this sense, however it is more flexible and it only targets a single, specified document.

Requires Programming Rights to function.

Note: If you install this with Extension Manager or manual import, the page also contains rights set to allow only the XWiki.XWikiAdminGroup to view, edit and delete the page, to avoid misuse. Of course, you can change the rights as you wish.

change creator, author or contentAuthor.png


Below is the source to copy/paste in a new document in your XWiki instance, in case you can/will not use Extension Manager or direct XAR import to install it.

#set ($documentReferenceString = "$!request.documentReference")
#set ($userReferenceString = "$!request.userReference")
#if ($documentReferenceString != '' && $userReferenceString != '')
 #set ($documentReference = $services.model.resolveDocument($documentReferenceString))
 #set ($document = $xwiki.getDocument($documentReference))
 #if ($document.isNew())
   {{error}}The document [$document] does not exist, so we can't change its creator.{{/error}}
   #set ($userReference = $services.model.resolveDocument($userReferenceString))
   #set ($internalDocument = $document.document)
   #if ($request.creator == 'true')
     #set ($discard = $internalDocument.setCreatorReference($userReference))
   #if ($ == 'true')
     #set ($discard = $internalDocument.setAuthorReference($userReference))
   #if ($request.contentAuthor == 'true')
     #set ($discard = $internalDocument.setContentAuthorReference($userReference))
   #set ($discard = $xwiki.xWiki.saveDocument($internalDocument, "Changed creator, author or contentAuthor document fields to $userReference", $xcontext.context))
   {{success}}Changed creator, author or contentAuthor fields for document [[$documentReference]] to [[$userReference]]{{/success}}
  Change the creator, last author or content author fields for an existing document with a given user.

    <form action='' class='xform'>
        <dt><label for='documentReference'>Document to change</label></dd>
        <dd><input type='text' name='documentReference' class='suggestDocuments withTip' value='Document reference'/></dd>

        <dt><label for='userReference'>User to set</label></dd>
        <dd><input type='text' name='userReference' class='suggestUsers withTip' value='User reference'/></dd>

        <dt>Fields to change:</dt>
          <label for='creator'>
            <input type='checkbox' name='creator' value='true' checked='checked'/>
          <label for='author>
            <input type='checkbox' name='author' value='true' checked='checked'/>
          <label for='contentAuthor>
            <input type='checkbox' name='contentAuthor' value='true' checked='checked'/>
            Content Author

          <input type='submit' value='Change'/>

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Get Connected