Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to get list of users and their last login using user macro


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">
<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>

#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($ == true)
#set($count = $count + 1)
<td class="confluenceTd">$count</td>
<td class="confluenceTd">#usernameLink($</td>
<td class="confluenceTd">$</td>
<td class="confluenceTd">$user.lastSuccessfulLoginDate</td>
<td class="confluenceTd">$user.directoryId</td>


Output which I get:

Screenshot (170).png


1 answer

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. 

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events