I have code (xwiki 12.2):
{{velocity}}
$services.user.getProperties("xwiki:XWiki.Pablo"))
{{/velocity}}
and get
org.xwiki.user.internal.document.DocumentUserProperties@6099bf2c
How to get email or first_name from there?
I want to use it for users from group:
$allGroupsInAllWikis = $services.user.group.getMembers('xwiki:XWiki.XWikiAdminGroup')
And I get array
$allGroupsInAllWikis = [xwiki:XWiki.Pablo, xwiki:XWiki.Martinez]
, so in loop I would get email for each user.
Hi, the doc is at https://extensions.xwiki.org/xwiki/bin/view/Extension/User%20Module/API/ (I’ve added a link to the UserProperties sources). Note that javadoc is available at https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/API/
Which leads to XWiki Platform - User - API 12.2 API which leads to UserProperties (XWiki Platform - User - API 12.2 API)
For example:
{{velocity}}
$services.user.getProperties("xwiki:XWiki.Pablo").getEmail()
{{/velocity}}
So I use
$services.user.getProperties("xwiki:XWiki.Pablo").getEmail()
$services.user.getProperties("xwiki:XWiki.Martinez").getEmail()
and for both get the same email address (email of logged in user)
when I use fake user I get still the same email
$services.user.getProperties("xwiki:XWiki.NNNNNNNNNN").getEmail()
Now I workaround it with:
{{velocity}}
#set($allGroupsInAllWikis = $services.user.group.getMembers('xwiki:XWiki.XWikiAdminGroup'))
#foreach($prop in $allGroupsInAllWikis)
#set($userDoc = $xwiki.getDocument($prop))
$userDoc.email
#end
{{/velocity}}
Thanks, you’ve found a bug in the new user api! Could you report a bug on XWiki Platform - XWiki.org JIRA?
Note, the issue is a velocity method signature mapping (the wrong method signature is used), and thus you get the properties for the current logged-in user.
Thanks!
So thats mean that this need new version of xwiki to fix or juzt extension update?
created:
https://jira.xwiki.org/browse/XWIKI-17169
New version of XWiki (although you could patch your version too). But two things:
Thanks, I’ll fix it tomorrow morning.