If you need to keep track of when users have last accessed Confluence here’s a handy user macro for producing a list of the last login dates of users who have access to a Confluence space.
To create the macro:
1. Login in to Confluence as a Confluence Administrator
2. Select Browse -> Confluence Admin
3. Select User Macros -> Create a new user macro
4. Enter the information as provided below:
Template:
## Macro title: Last Login
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 11/02/2012
## Installed by: <your name>
## 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">User</th>
<th class="confluenceTh">Last Successful Login</th>
</tr>
#foreach($user in $users)
## list the last login date of users who can view the current space
#if ($permissionHelper.canView($user, $space))
<tr>
<td class="confluenceTd">#usernameLink($user.name)</td>
#if (!$loginManager.getLoginInfo($user).lastSuccessfulLoginDate)
<td class="confluenceTd" style="background-color:#ff0000"><strong>NEVER</strong></td>
#else
<td class="confluenceTd">$action.dateFormatter.formatDateTime($loginManager.getLoginInfo($user).lastSuccessfulLoginDate)</td>
#end
</tr>
#end
#end
</table>
You can then use the following macro when editing a page:
{lastlogin}
or select the macro from the Macro Browser:
With thanks to Sandro Herrmann from Communardo and Remo Siegwart from bitvoodoo for their answers to “How can I show the page permissions in the page itself?” and “Macro that produces a list of users’ last login date?” over at Atlassian Answers for the inspiration.




Pingback: Confluence Community Management Dashboard | Networked Collaboration
Thanks for the credit Andrew! Great post!
You’re welcome Remo. Thanks for the comment and for the post over on Atlassian Answers.