Display a user email

Last modified by Vincent Massol on 2021/03/18 11:29

email_addDisplay the email of a requested user
Type
Category
Developed by

Andreea Chirica

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

Use the script below to retrieve a specific user email. 

With XWiki 12.2+ (see User Scripting API):

{{velocity}}
$services.user.getProperties("TestUser").email
{{/velocity}}

With XWiki older than 12.2:

{{velocity}}
$xwiki.getDocument("xwiki:XWiki.TestUser").getObject('XWiki.XWikiUsers').getProperty('email').value
{{/velocity}}

Example

I edited a page part of an AppWithinMinutes application ("My App"). Then, I added in the "Content" type of field the script (in Source mode) to display the email address of a picked user on a "User" type of field. For each picked user, the need would be to update their profile name in the "xwiki:XWiki.[profilename]".

AddScriptGetEmailSource.png
Adding the script in Source mode

Result

ResultScriptDisplayedEmail.png

     

Get Connected