You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
When I try to get the list of users with the user macro where I need the users last login and login count. But I'm unable to get that through the macro.
Is there any logic where I can get the users last login and the login count.
Macro which I've created:
## Macro title: Last Login
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Poornika Reddy Ekkati
## Macro to display the last login date of users who have access to the current space
## @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($loginManager = $containerContext.getComponent('loginManager'))
#set($users = $userAccessor.getUsers())
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Count</th>
<th class="confluenceTh">User</th>
<th class="confluenceTh">Login Name</th>
<th class="confluenceTh">Last Successful Login</th>
<th class="confluenceTh">Directory</th>
</tr>
#set($count = 0)
#foreach($user in $users)
## list the last login date of users who can view the current space
#if($user.directoryId == 1)
#if($user.active == true)
#set($count = $count + 1)
<tr>
<td class="confluenceTd">$count</td>
<td class="confluenceTd">#usernameLink($user.name)</td>
<td class="confluenceTd">$user.name</td>
<td class="confluenceTd">$user.lastSuccessfulLoginDate</td>
##action.dateFormatter.formatDateTime($loginManager.getLoginInfo($user.name)
<td class="confluenceTd">$user.directoryId</td>
#end
#end
#end
</table>
Output which I get:
I don't think you can achieve this through the standard macro. Creating a user macro might be a solution but I can not help you with that.
Thank you patrick. I've created a user macro, but it doesn't print the Last Successful Login.
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.