API to be used within Velocity Templates (v 3.4)

The User Profile Plugin extends the Velocity context by a component which allows to access user profile data from Velocity templates.
The velocity context component has the name uppVelocityApi. It provides one method with the following signature:

getProperty(user, profileElementName):

  • This method returns the value of the given profile element for the given user. It accepts the following parameters:
    • user: The user to retrieve the value for. Type: com.atlassian.user.User
    • profileElementName: Default name of the profile element, typically the English name. Type: String
  • Profile element names do not need to be unique. This method will return the value of the first found field with the name, which is visible (i.e. not hidden). To determine the first field, the order as defined at the administration is used.

Usage

#set( $user = $userAccessor.getUser("userWithProfileElement") )
#set($profileElementName = "Mobile Phone" )
##set($mobileNumber = $uppVelocityApi.getProperty($user, $profileElementName) )