Is there a macro to get a user profile attribute?
Asked by Victor Gleim:

There are various attributes in the user profile, like: Location, Department, Phone. I'm wondering if anybody developed a macro to get a value of one of the attributes for a particular user. E.g. I need to put a phone number of vgleim user on a Confluence page.


Answers:
author: Stephen Deutsch
body: If you're not afraid of using a user macro, you could do this to put the name and phone number of either a specific user or a group of users on a page:

```
## @param User:title=Username|type=username|desc=Select username to display## @param Group:title=Group|type=string|desc=Enter group to display.#set ( $Integer = 0 )#set ( $userName = "" )#set ( $userName = $paramUser )#set ( $groupName = "" )#set ( $groupName = $paramGroup )#set ( $group = "" )#set ( $user = "" )#set ( $containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager') )#set ( $getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null) )#set ( $containerManager = $getInstanceMethod.invoke(null,null) )#set ( $containerContext = $containerManager.containerContext )#set ( $userDetailsManager = $containerContext.getComponent('userDetailsManager') )#if ( $userName != "" )  #if ( $Integer.parseInt($generalUtil.getBuildNumber()) &gt; 4300 )    #set ( $user = $userAccessor.getUserByName($userName) )  #else    #set ( $user = $userAccessor.getUser($userName) )  #end  #if ( $user != "" )    #set ( $phone = $userDetailsManager.getStringProperty($user, "phone") )    ##set ( $im = $userDetailsManager.getStringProperty($user, "im") )    ##set ( $website = $userDetailsManager.getStringProperty($user, "website") )    ##set ( $position = $userDetailsManager.getStringProperty($user, "position") )    ##set ( $department = $userDetailsManager.getStringProperty($user, "department") )    ##set ( $location = $userDetailsManager.getStringProperty($user, "location") )    &lt;p&gt; #userLink($user) - $!phone &lt;/p&gt;  #else    &lt;p&gt; User $userName not found. &lt;/p&gt;  #end#elseif ( $groupName != "" )  &lt;p&gt; Members in group ${groupName}: &lt;/p&gt;  #set ( $group = $userAccessor.getGroup($groupName) )  #if ( $group != "" )    #set ( $members = $userAccessor.getMemberNames($group) )    #foreach ( $member in $members )      #if ( $Integer.parseInt($generalUtil.getBuildNumber()) &gt; 4300 )        #set ( $user = $userAccessor.getUserByName($member) )      #else        #set ( $user = $userAccessor.getUser($member) )      #end      #set ( $phone = $userDetailsManager.getStringProperty($user, "phone") )      ##set ( $im = $userDetailsManager.getStringProperty($user, "im") )      ##set ( $website = $userDetailsManager.getStringProperty($user, "website") )      ##set ( $position = $userDetailsManager.getStringProperty($user, "position") )      ##set ( $department = $userDetailsManager.getStringProperty($user, "department") )      ##set ( $location = $userDetailsManager.getStringProperty($user, "location") )      &lt;p&gt; #userLink($user) - $!phone &lt;/p&gt;    #end  #else    &lt;p&gt; Group $groupName not found. &lt;/p&gt;  #end#end
```

comments: author: iamgoingtosneeze
body: Firstly - thank you for your efforts. I know this a few years ago, but I've copied quite a few of your examples over the last couple of months! Quick question though - any idea why this doesn't work in the latest version of confluence? I'm using the latest version of the confluence sdk and I just cannot get info other than the name. It partly works in that I get the full name back, but I specifically want the IM back for the user. The getPropertyString comes back empty. Thanks in advance.


author: RVal
body: One of the options is to install Communardo User Profile plugin. It can synchronize user attributes from AD and provides a few profile macros you can use on your pages:

<https://marketplace.atlassian.com/plugins/de.communardo.confluence.plugins.userprofile>