List All Users within Date Range


(Nick Papadatos) #1

Matrix Version: 5.3.4.2

Has anyone ever built an Asset Listing Page that lists all users who have logged into Matrix eg; over the last 12 months?

In a table of:
Headers,
AssetID - Username - Email - Last LoggedIn Date

Any help would be appreciated
N


#2

This should be quite straight forward with standard keywords. As you’ve asked for a table:

Asset Listing page

Asset type
User + inherited

Page Contents
<table>
<tr>
<th>Asset ID</th>
<th>Username</th>
<th>Email Address</th>
<th>Last Login</th>
</tr>
%asset_listing%
</table>

User format
<tr>
<td>%asset_assetid%</td>
<td>%asset_attribute_username%</td>
<td>%asset_attribute_email%</td>
<td>%asset_attribute_login_date^date_format:j F Y% (/your preferred date format)
</tr>

Sorting
Asset Attribute Value > User > Login Date

Depending on the syntax of your usernames I would also throw in an %asset_short_name% column or similar for more readable names.

Good luck!


(Peter McLeod) #3

Hi Nicky

To filter logins from the last 12 months using matrix keyword modifiers, you could do something like below (… though there is probably a simpler method):

%begin_asset_attribute_login_date^contains:----------%
%else_asset%

     %begin_asset_attribute_login_date^date_format:U^gte:{globals_date_U^subtract:31536000}%
        %asset_attribute_first_name% %asset_attribute_last_name%<br>
     %end_asset%

%end_asset%

The initial condition checks that there is a last login date to compare - null values seem to output -------- for the date component.
The date modifier U converts the date to a unix timestamp.
The subtracted value 31536000 = 1 year in seconds to make it equal to the timestamp units.
For a different time period just calculate the total seconds (eg a year = 60 secs * 60 mins * 24 hours * 365 days).
Then if the last login date is greater than or equal to the current date minus 1 year than the user name is printed.

It might also is easier to implement using server side JS…
Thanks
Peter


(Nick Papadatos) #4

Asset types to list? Is it User Login / User Login Via SAML etc?

Thanks
N


(Nick Papadatos) #5

Thanks Peter - I’ll give this a go as well.

Yes SSJS would be preferable but it’s not available in version

Cheers
N


(Nick Papadatos) #6

Sorry guys I left out the most important information.
Give me a list users who have logged in via the /_edit interface in the past 12 months.

Apologies for the confusion

Cheers
NickyP


(Bart Banda) #7

Easiest thing would be to asset list all your users and sort them by last login date, and then maybe group by last 12 months somehow, or use keyword modifiers to hide all other results. If you have thousands of users though, this list generation might time out and you might have to use a search page instead.
Unfortunately there is no way to differentiate a login between /_edit and /_admin, but if your Edit+ users are all Simple Edit Users, then you could limit your listing to just that user type.


(Nick Papadatos) #8

Thanks Bart - I thought was the case. I just needed clarification to pass that on to those who wanted that info
Cheers
N