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?:
Thank you in advance!
Beste regards
Manuel
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 < and >
Thank you in advance!
Beste regards
Manuel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is the code of the macro as it is working for me:
## @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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Most probably you have no data in these fields on your profile.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, I tried with Confluence 6.15.9 - we don't have Confluence 7 yet. Maybe this is not working with Confluence 7 anymore.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same question in the developer Community:
Maybe someone will find an answer there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.