It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Access to "About Me" text in user macro

Hi everyone,

I would like to write a simple user macro quite similar to the built-in macro "User Profile".

The macro should have the input of type "username" and the output...

User Full Name

$action.getUserFullName($paramUser))

User Profile Picture

$userAccessor.getUserProfilePicture($userAccessor.getUserByName($paramUser)).getUriReference()

 

That went well..but how do I get access these pieces of information?:

  1. the "About Me" text from the Profile
  2. the Phone-Number from the Personal Information
  3. and the position from the Company Information

 

Thank you in advance!

 

Beste regards
Manuel

1 answer

1 vote
Thomas Schlegel Community Leader Jan 30, 2020

Hi @Manuel ,

the macro from 2012 by @Andreas_Gounaris is still working (I tried it just now) and returns exactly what you need. You can find it here:

https://community.atlassian.com/t5/Jira-questions/How-do-I-get-the-quot-About-Me-quot-field-from-a-confluence-user/qaq-p/130078

I'm glad it still works, thanks @Thomas Schlegel  for mentioning! 

Like Thomas Schlegel likes this

Hi @Thomas Schlegel ,

Thank you for your reply. The description in the example you gave me is exactly what I was trying. I unserstand the logic of the code but apperently I'm stuck somewhere - maybe in the datatype I am handing over to the methods.

If I copy-paste the code of @Andreas Gounaris the out put looks like this:

<div> <b>Website: </b> $userDetailsManager.getStringProperty($action.remoteUser, 'website') </div> <div> <b>Location: </b> $userDetailsManager.getStringProperty($action.remoteUser, 'location') </div> <div> <b>About Me: </b> <div id="profile-about-me-content">$renderedAboutMe</div> </div>

An if I copy-paste the code of @Stefan Baader the output looks like this

<b>Profildaten von User $user.fullName ($user.name)</b> <div> <b>Website: </b> $userDetailsManager.getStringProperty($user, 'website') </div> <div> <b>Location: </b> $userDetailsManager.getStringProperty($user, 'location') </div> <div> <b>Position: </b> $userDetailsManager.getStringProperty($user, 'position') </div> <div> <b>Phone: </b> $userDetailsManager.getStringProperty($user, 'phone') </div> <div> <b>Department: </b> $userDetailsManager.getStringProperty($user, 'department') </div> <div> <b>confluence.user.profile.email: </b> $userDetailsManager.getStringProperty($user, 'email') </div> <div> <b>About Me: </b> $renderedAboutMe </div>

Please help me to find the link. I'm probably close. Even if I enter "<...>" instead of &lt; and &gt;

Thank you in advance!

Beste regards
Manuel

Thomas Schlegel Community Leader Jan 31, 2020

this is the code of the macro as it is working for me:

image.png

## @noparams

#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'))
#set($personalInformationManager = $containerContext.getComponent('personalInformationManager'))
#set($wikiStyleRenderer = $containerContext.getComponent('wikiStyleRenderer'))

#set($pi = $personalInformationManager.getPersonalInformation($action.remoteUser))
#set($renderedAboutMe = $wikiStyleRenderer.convertWikiToXHtml($pi.toPageContext(), $pi.getBodyAsString()))

<div>
<b>$action.getText('confluence.user.profile.website'): </b>
$userDetailsManager.getStringProperty($action.remoteUser, 'website')
</div>
<div>
<b>$action.getText('confluence.user.profile.location'): </b>
$userDetailsManager.getStringProperty($action.remoteUser, 'location')
</div>
<div>
<b>$action.getText('personal.info'): </b>
<div id="profile-about-me-content">$renderedAboutMe</div>
</div>

This looks quite familiar to me, though the result on the confluence page looks like..

Website: $userDetailsManager.getStringProperty($action.remoteUser, 'website')
Location: $userDetailsManager.getStringProperty($action.remoteUser, 'location')
About Me:
$renderedAboutMe

We use Confluence Server 7.2.0. Is it maybe some configuration that's making the problem?

Any ideas?

Most probably you have no data in these fields on your profile.

No, I do. :-( 

Thomas Schlegel Community Leader Jan 31, 2020

Hmm, I tried with Confluence 6.15.9 - we don't have Confluence 7 yet. Maybe this is not working with Confluence 7 anymore. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,532 views 6 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you