Add user log date to admin
« on: March 15, 2013, 03:44:32 AM »
I would like to add the last logged in date to the member profile list in admin. I currently delete members that have not recently been active and this would save me the time of opening each profile to see the date. I'm still on the older version 2.1.8.

Any help is much appreciated. I tried to get into the old forum, but no luck.

Thanks.
MTL

osdate 2.6  php 5.3

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Add user log date to admin
« Reply #1 on: March 15, 2013, 08:18:28 AM »
Hi

in your admin/profile.tpl add a extra colum with:
Code: [Select]
{checkuser userid=$item.id checkfor='online'}
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

Re: Add user log date to admin
« Reply #2 on: March 15, 2013, 10:58:54 AM »
Thank you, that nearly got it. I was actually hoping for the date and not just the "active within the past..." info, but this might actually be better.

To be better I would need to add a couple of extra time ranges though, like an "Active within 3 months" and "Active within 6 months" would be great. Not sure how do that either so any help on that is appreciated.

Also, how to make it sortable by the date, somehow in this code in the same profile.tpl -
            <th nowrap><a href="?sort=?????? ..... &amp;type={$sort_type}">Active</a></th>

A big THANK YOU for your help on this.
MTL

osdate 2.6  php 5.3

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: Add user log date to admin
« Reply #3 on: March 15, 2013, 11:26:24 AM »
Hi

Look in your - libs > Smarty > plugins > functions.checkuser.php
I don't use the colored  "Active within X months" on my site, only the time and date...
if you want that edit the if ($checkfor == 'online') in functions.checkuser.php and make it like this:

Code: [Select]
if ($checkfor == 'online') {
/* Check if the user is online */
    $online=$osDB->getOne('select count(onl.userid) from ! as onl, ! as usr where onl.userid = ? and usr.id = onl.userid and usr.allow_viewonline = ? ', array(ONLINE_USERS_TABLE, USER_TABLE, $userid,'1'));
    if (isset($online) && $online > 0) {
    $returnme='<b><font color="'.$lang['useronlinecolor']['online_now'].'">'.$lang['useronlinetext']['online_now'].'</font></b>';
    } else {
$lastvisit = $osDB->getOne('select lastvisit from ! where id = ?', array(USER_TABLE, $userid) );
if (!isset($lastvisit) ) $lastvisit = time() - 3456000; /* 4-0 days back */
$time_now = time();

  $dateLast = date('d M Y',$lastvisit);
if ($lastvisit > ($time_now-86400) ) {
                /* Active in last 24 hours */
                   $returnme= $dateLast;
            } elseif ($lastvisit > ($time_now-259200) ) {
                /* Active in last 3 days */
                   $returnme= $dateLast;
            } elseif ($lastvisit > ($time_now-604800) ) {
                /* Active in last 7 days */
                   $returnme= $dateLast;
            } elseif ($lastvisit > ($time_now-2592000) ) {
                /* Active in last 30 days */
                   $returnme= $dateLast;
            } else {
                   $returnme= $dateLast;
            }
    }

To make it sortable by the date in Admin is a timeconsuming modification I did not do yet
Maybe in the future..
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

Re: Add user log date to admin
« Reply #4 on: March 16, 2013, 10:31:42 AM »
That did the trick, thanks again for your help with this.
MTL

osdate 2.6  php 5.3