Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Access to "About Me" text in user macro

Manuel January 30, 2020

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 Champion
January 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

andreasgounaris January 31, 2020

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

Like Thomas Schlegel likes this
Manuel January 31, 2020

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 Champion
January 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>
Manuel January 31, 2020

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?

Thomas Schlegel
Community Champion
January 31, 2020

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

Manuel January 31, 2020

No, I do. :-( 

Thomas Schlegel
Community Champion
January 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. 

Thomas Schlegel
Community Champion
February 4, 2020

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events