Gossamer Forum
Quote Reply
Non-Posting Users
Has anybody thought of a way to handle non-posting users? I have several users who create accounts and never post. I wondered if they was a way to expire their account if they have been a member for a certain amount of time, but have never contributed. Does anyone have anything setup to handle this?

Sean

Last edited by:

SeanP: Aug 19, 2005, 11:16 AM
Quote Reply
Re: [SeanP] Non-Posting Users In reply to
Don't know if this will work for you but we had the criteria to delete users who registered and validated but then never logged on (for 75 days) or posted. If they have ever posted then they won't make this list but you could probably change the criteria to skip that and just look for inactivity. Criteria would be changed by manipulating the two global files.

We made an HTML page for the admin template and added it as a quick link in the admin portal:
Code:
<%--File
====
user_inactive_list.htmlDescription
===========
Inactive Users Admin Page--%>
<html>
<head>
<title>Inactive Users List</title>
</head><body>
<center>
<table>
<tr>
<td><font size=4><b>
Users who registered more than 75 days ago but never logged on since their registration. </b></font></td>
<td align=right>
</td>
</tr>
</table><form action="admin.cgi?" method="POST" enctype="multipart/form-data">

<br><table>
<tr>
<td><b>User ID</b></td>
<td><b></b></td>
<td><b>User Name&nbsp;&nbsp;&nbsp;</b></td>
<td><b>Date Registered&nbsp;&nbsp;&nbsp;</b></td>
<td><b>Last Logon</b></td>
</tr>
<%u_logonlast%>
<tr>
<td colspan=5>
</td>
</tr><tr>
<td colspan=5> <center><br><br><font size=3><b>WARNING: By clicking the button below you are <u>permanently</u> deleting users from the VP Database!</b></font><br>
<input type="submit" class="submit" name="do=page;page=local/user_inactive_delete.html" value="Perform Deletions">
<br>
</center></td>
</tr>
</table>
</form><br><br>
</center>
</body>
</html>

Then we have an admin template addition for the deletion page:
Code:

<%--
File
====
user_inactive_delete.html
Description
===========
Inactive Users Admin Deletion Page
--%>
<%u_inactive_delete%>


Then there are the two admin globals that the above pages use:
Code:


u_logonlast
sub {
my $days_old = 75;
my $output;
require GT::SQL::Condition;
require GT::Date;
my $table = $DB->table('User');
my $cond = GT::SQL::Condition->new(
'user_last_logon', 'IS', \'NULL',
'user_registered', '<', time - 24 * 60 * 60 * $days_old
);
$table->select_options("ORDER BY user_registered ASC");
my $sth = $table->select(['user_username', 'user_id', 'user_registered'],$cond);
while (my $result = $sth->fetchrow_hashref) {
my $uname = $result->{user_username};
my $uid = $result->{user_id};
my $ulast = $result->{user_last_logon} ? GForum::date($result->{user_last_logon}, 1) : "<i>Never logged on</i>";
my $ureg = GT::Date::date_get($result->{user_registered});
$output .= " <tr><td> $uid </td><td>&nbsp;&nbsp;</td><td>$uname</td><td>$ureg</td><td>$ulast</td></tr>";
}
return \$output;
}



u_inactive_delete global:
sub {
require GT::SQL::Condition;
require GT::Date;
my $del_count = 0;
print "<html><head><title>Inactive Users - Deletion Preview</title></head><body><center><br><br><font size=4><b>Users Deleted</b></font><br><br>";
my $days_old = 75;
my $table = $DB->table('User');
my $cond = GT::SQL::Condition->new(
'user_last_logon', 'IS', \'NULL',
'user_registered', '<', time - 24 * 60 * 60 * $days_old
);
$table->select_options("ORDER BY user_registered ASC");
my @ids = $table->select("user_id", $cond)->fetchall_list();
foreach my $id (@ids) {
print "Deleting user: $id<br>";
$table->delete({ user_id => $id });
$del_count++;
}
print "<br><br><font size=4><b>Total Users Deleted: $del_count</b></font></center></body></html>";
}


Herpeton
VegPeople.com