Featured Idea - Last Logged In...

By rjbathgate - April 28, 2011 - edited: April 28, 2011

Hello,

Just a nice featured/addon idea which I think would be great...

"Last Logged In"

I.e. stores date and time in a field within the Accounts table for when that user last logged in.

Ideally either when logging in through the Website Membership function, and also straight into cmsb admin back end.

Would be very handy for CRM type setups :)

I was thinking it'd be quite easy to do as a hack into the Login function, but I'm not sure how to do it as a plugin which doesn't loose the hack up CMSB update ;)

That's my friday 2 cents :)

Cheers!!
Rob

EDIT:

I should really search the forum before posting...

http://www.interactivetools.com/iforum/Products_C2/CMS_Builder%3A_Plugins_%26_Add-ons_F40/gforum.cgi?post=81869;search_string=last%20logged%20in;t=search_engine#81869

I see it's already part of the Membership Plugin.

Oppps.

Re: [rjbathgate] Featured Idea - Last Logged In...

By Dave - April 29, 2011

Hi Rob,

We also added it in 2.08 as a default field under User Accounts that is also updated when you login to the CMS.

Hope that helps! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Featured Idea - Last Logged In...

By rjbathgate - May 1, 2011

bonza, thanks :)

Re: [Dave] Featured Idea - Last Logged In...

By gversion - March 20, 2012

Hi David,

I can see the field "Last Login", which is great!

Can you tell me how I can setup this to be included as an "Advanced Search" field so that I can list all users that haven't logged in since a particular date?

Or to put it another way, I'd like to be able to list all users that logged in before a certain date and all users that logged in after a certain date.

Thank you,
Greg

Re: [gversion] Featured Idea - Last Logged In...

By Dave - March 20, 2012

Hi Greg,

First, turn on the "Date Picker" feature under: Admin > General Settings > Use Datepicker (was was added in 2.14 and isn't required)

Next, edit the accounts section and click on "Search"
/cmsAdmin//admin.php?menu=database&action=editTable&tableName=accounts#search

Add these lines
_all_
Last Login Before|lastLoginDate|max
Last Login After|lastLoginDate|min

Then go to your accounts editor:
/cmsAdmin/admin.php?menu=accounts

Click "Advanced Search >>", click on the date fields, then click search.

One last tip, if you add "lastLoginDate" to the list of fields to be displayed on the list page it will be easier to confirm the matching is working correctly (it seemed to do so in my quick tests).

Let me know how it goes. Cheers! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [gversion] Featured Idea - Last Logged In...

By Dave - March 20, 2012

Hi Greg,

You don't need the _all_ on the first line and can remove that if needed. It's just for keywords searches.

The date icon doesn't appear on those search fields but I've added it to the next release.

If you are comfortable modifying PHP code you can try adding it yourself. Just open /cmsAdmin/lib/menus/default/list_functions.php then:
- Search for: jqueryUI
- Replace this
// custom datepicker code - this is only called is jqueryUI datepicker is loaded
$html .= "\n<script type='text/javascript'>";
$html .= " $(function() { ";
$html .= " if ($.datepicker != undefined) { $('[name={$name}]').datepicker({ dateFormat: 'yy-mm-dd' }); }";
$html .= " });";
$html .= "</script>\n";
}

- With this:
// custom datepicker code - this is only called is jqueryUI datepicker is loaded
$jsDateFormat = @$fieldSchema['showTime'] ? "yy-mm-dd 00:00:00" : "yy-mm-dd";
$html .= <<<__HTML__
<script type='text/javascript'><!--
$(function() {
if ($.datepicker != undefined) {
$('[name={$name}]').datepicker({
showOn: 'button',
buttonImage: '3rdParty/jqueryUI/calendar.gif',
buttonImageOnly: true,
dateFormat: '$jsDateFormat'
});
}
});
//--></script>
__HTML__; // make sure there are no spaces to the left of __HTML__;
}


Hope that helps! Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com