Displaying Additional User Information from the User Profile Plugin
The User Profile Plugin lets you add additional information to user profiles. This recipe explains how to display user information from the User Profile Plugin.
This recipe works with User Profile Plugin versions 1.10 and higher.
Displaying Extended User Details on a Page
In a page template, use the following information to output user details:
$upp.getProperty($page.author, "Department") --> Outputs the built-in "Department" property
$upp.getProperty($page.author, "Hobbies") --> Outputs the custom "Hobbies" property
When a statement in Velocity returns null
, Velocity will output the statement itself. For example, if $searchResult.getProperty("Department")
is not set (is null
), the template will output $searchResult.getProperty("Department").
If you want to output "" (empty string) instead, you can specify the statement as $!statement
. In the example, when the statement is changed to $!searchResult.getProperty("Department")
(not the additional bang) and the property is not set, the template will output "" (empty string).
Displaying Extended User Details in the Search Results
Create a template file search-user.vm in the top level of the theme directory (read more about user search in the User Search Recipe):
search-user.vm
#foreach($searchResult in $searchResults.results)
<li>
<h3>$searchResult.displayTitle</h3>
<p>Custom Property: $upp.getProperty($searchResult.object, "Custom Property")</p>
<li>
#end