Access ConfluenceUserProfile in macros

Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2013

Does anyone know if its possible to get a reference to the ConfluenceUserProfile class (com.atlassian.sal.confluence.user.ConfluenceUserProfile) in a macro?

2 answers

1 accepted

0 votes
Answer accepted
Ryan Goodwin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2013

Hi Matt,

Accessing the user profile macro in a velocity template would look like this:

$helper.renderConfluenceMacro("{profile:user=Ryan}")

For XHTML like this:

<ac:macro ac:name="profile">

    <ac:parameter ac:name="user">admin</ac:parameter>

</ac:macro>

To access from a user macro, you could do a modification of this tutorial:

http://blog.networkedcollaboration.com/2012/03/22/confluence-list-space-administrators-user-macro/

by accessing the methods you would like from the class:

https://developer.atlassian.com/static/javadoc/confluence/4.2.13/reference/com/atlassian/sal/confluence/user/ConfluenceUserProfile.html

Hope this helps!

Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2013

Thanks for the response. I was actually trying to get at a specific method on the ConfluenceUserProfile class, but found a way to access it via a different class in my macro.

Ryan Goodwin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2013

Glad you were able to figure it out. Please share your solutions if possible so others looking for Answers can bask in your Guru-ness :)

Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2013

Well, I was trying to get the profile picture for the creator of a blog post so that I could add a little "About the author" section on each new blog entry (without the author having to do anything).

Turns out I missed the method I needed when first looking over the User class, but it's right there.

In the blog page decorator, you can use the following to get the user profile picture:

## getUser returns an object of type User
#set($blogWriter = $userAccessor.getUser($page.getCreatorName()))
## getUserProfilePicture returns an object of type ProfilePictureInfo
#set($pic = $userAccessor.getUserProfilePicture($blogWriter))
#set($picPath = $pic.getDownloadPath())

0 votes
Ryan Goodwin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2013

Hi Matthew,

Do you mean get a user profile to show up on a page, or in another macro? Is this something you're trying to do programmatically?

https://confluence.atlassian.com/display/DOC/User+Profile+Macro

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events