Hi,
{{velocity}}
$xwiki.getDocument('XWiki.Admin').getObject('XWiki.XWikiUsers').getValue('test')
{{/velocity}}
Where 'test' is the property name (not property pretty name).
Note that by doing $userObj.getXWikiObject(), you are accessing the
restricted API BaseObject class (which is intended to be used by java code
and which is different from the api.Object class). You should be using
$userObj directly and according to the api [1][2], since it is intended to
be used by the velocity code (and does not require programming rights,
compared to $userObj.getXWikiObject() which requires PR).
Also, for getting property values, you can use object.getValue(...)
(recommended) directly or you can do object.getProperty(...).getValue().
Using object.get(...) might look like it has the intende effect, but
actually it displays the object's property, meaning that in inline edit
mode it will return an HTML text input instead of the string value of the
object's property.
Hope this helps,
Eduard
----------
[1]
http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/or…
[2]
http://platform.xwiki.org/xwiki/bin/view/DevGuide/API
On Fri, Sep 18, 2015 at 10:31 PM, Cyre, Jeff (US) <jeff.cyre(a)baesystems.com>
wrote:
I am having trouble getting custom properties from a
user profile.
I have added a property of type String called "Code"
{{velocity}}
#set($fn= $userObj.getXWikiObject().get("first_name").value)
$fn
#set($c= $userObj.getXWikiObject().get("Code").value)
$c
{{/velocity}}
When the code runs it displays
--------------------
Jeff
$c
--------------------
If I go to the user profile the property Code has a value. I have checked
the capitalization and it is correct.
What is the correct way of doing this?
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users