View Full Version : Mass Delete/Mass Email inactive users.
Mass Delete old users/Mass Email inactive users.
I would like a way to do the above. Perhaps a way to email all users that havent visited in x days, and tell them to do so. If they do not send another email x days later to tell them they will need to visit in x days or acct will be deleted then in x days delete it.
Just a thought. I know I have a lot of users that sign up and forget to come back lol.
For example say once every ten days you clean up your board. First time you email all people that have not posted in say 30 days. 10 Days later you email everyone that hasnt visited in 40 days telling them that if they still wish to be a member to log in (send url) then ten days later purge who ever hasnt logged in after second email.
See what I mean?
-Brian
Yup - I'll have a think about that one!
John
[B]Mass Delete old users/Mass Email inactive users.
I need this feature too for my classes which change every semester
Has anyone worked on this? I would love to see a feature like this.
I like this idea! :) Definitely a thing to code/hack in the future.
has anyone come up with this yet?
Ok,
I have been working on the remove old members hack but I know I am doing something wrong here.
Here is what I have:
if ($action=="joindates") {
echo "<p>Remove by length of membership</p>\n";
echo doformheader("thread","doremovejoindate");
echo "<table border=0>";
echo makeinputcode("Delete accounts older than x days:","joindateremove","");
echo makeinputcode("Number of Posts:","joinpostsremove","");
echo doformfooter("Submit");
exit;
}
if ($action=="doremovejoindate") {
echo "<p>Deleting...</p>";
$datecut=time()+($joindateremove*86400);
$postcut=$DB_site->query("SELECT joindate FROM user WHERE joindate=$datecut");
$postcuts=$postcut[joindate];
if ($joinpostsremove<=2 AND $postcuts=$datecut) {
$DB_site->query("DELETE FROM user WHERE joindate=$datecut");
$DB_site->query("DELETE FROM user WHERE posts<=$joinpostsremove");
echo "<p>Accounts removed successfully! It is recommend that you <a href=\"misc.php\">update counters</a> now.</p>";
} else {
echo "<p>No Members match this criteria. Click <a href=\"index.php\">here</a> to return to the admin index page.</p>";
}
}
What I am trying to do is to remove only those members that are the number of days old that you input into the text box and also meet the number of posts requirement.
I set this to <=2 but would like for the script to look at the $joinpostsremove input and work off that.
The above is just where I got to and would like for some of you code warriors to look it over and add anything that you think is necessary so that you can put in correct code to delete members that are over X number of days old and have X number of posts. They should meet both criteria or you get the "No Members match......." message.
Thanks,
Parker
Hmm.. this is completely untested, and I dunno if it'll work:
if ($action=="joindates") {
echo "<p>Remove by length of membership</p>\n";
echo doformheader("thread","doremovejoindate");
echo "<table border=0>";
echo makeinputcode("Delete accounts older than x days:","joindateremove","");
echo makeinputcode("Number of Posts:","joinpostsremove","");
echo doformfooter("Submit");
exit;
} #end joindates
if ($action=="doremovejoindate") {
echo "<p>Deleting...</p>";
if (!is_int($joinpostsremove) and !is_int($joindateremove)) {
echo "Invalid entries.";
exit;
}
$datecut=time()+($joindateremove*86400);
if($cuts=$DB_site->query("SELECT username,userid FROM user WHERE (joindate<=$datecut AND posts<=$joinpostsremove)")) {
while($user=$DB_site->fetch_array($cuts)) {
$DB_site->query("DELETE FROM user WHERE userid=$user[userid]");
echo "$user[username] deleted...<BR>";
}
echo "<p>Accounts removed successfully! It is recommend that you <a href=\"misc.php\">update counters</a> now.</p>";
} else {
echo "<p>No Members match this criteria. Click <a href=\"index.php\">here</a> to return to the admin index page.</p>";
}
} #end doremovejoindate
HTH,
Ed:
Thanks for looking at this.
I keep getting the "Invalid Entries" line whenever I put any number in either place. So if I put in 365 for the number of days and 1 for the number of posts then I get the "Invalid Entries" line.
Also, I am not sure now that the script uses 86,400 as the number to use for calculation of the sign up date. In the import.php file it uses:
if ( ereg( "([0-9]{1,2})-([0-9]{1,2})-([0-9]{2,4})", $userinfo[datejoined], $regs ) ) {
$datejoined=mktime(0,0,0,$regs[1],$regs[2],$regs[3])-($timeoffset)*3600;
} else {
$datejoined=time();
}
Any ideas?
BTW, what does this do?:
if (!is_int($joinpostsremove) and !is_int($joindateremove))
Thanks,
Parker
[Edited by Parker Clack on 07-31-2000 at 11:34 PM]
Hmm... not sure why that invalid entries thing wasn't working. It was just to make sure the user entered an integer in both fields. Oh well, I just changed it up a little, but not it does a little bit different function :)
if ($action=="joindates") {
echo "<p>Remove by length of membership</p>\n";
echo doformheader("thread","doremovejoindate");
echo "<table border=0>";
echo makeinputcode("Delete accounts older than x days:","joindateremove","");
echo makeinputcode("Number of Posts:","joinpostsremove","");
echo doformfooter("Submit");
exit;
} #end joindates
if ($action=="doremovejoindate") {
echo "<p>Deleting...</p>";
if (!$joinpostsremove and !$joindateremove) {
echo "You didn't fill in a required field.";
exit;
//Another note since I'm thinking about it: this might not work either. I'm not sure if a "0" returns as false - try it.
}
$datecut=time()+($joindateremove*86400);
if($cuts=$DB_site->query("SELECT username,userid FROM user WHERE (joindate<=$datecut AND posts<=$joinpostsremove)")) {
while($user=$DB_site->fetch_array($cuts)) {
$DB_site->query("DELETE FROM user WHERE userid=$user[userid]");
echo "$user[username] deleted...<BR>";
}
echo "<p>Accounts removed successfully! It is recommend that you <a href=\"misc.php\">update counters</a> now.</p>";
} else {
echo "<p>No Members match this criteria. Click <a href=\"index.php\">here</a> to return to the admin index page.</p>";
}
} #end doremovejoindate
About 86,400: that's correct. The users registration date/time is stored as a unix timestamp, or seconds since Jan 1, 1970 (?). Since there are 86,400 seconds in a day, 365*86,400 would equal one year in seconds.
Ed:
A couple of things:
Shouldn't it be:
(joindate>=$datecut AND posts<=$joinpostsremove)
instead of:
(joindate<=$datecut AND posts<=$joinpostsremove)
if you are trying to remove those memberships that are older than the number of days that your wanting to take out?
I noticed that the } else { line doesn't work. If it takes out memberships it lists them like it should but if it doesn't find anything that matches the criteria it should give you the "No Members match....." line and it doesn't.
Also, the reason that I asked about the time stamp thing
is because my own joindate is listed as 867992400. I have been on our forum for 1122 days. If you multiply this by
the 86,400 you get 96940800. Shouldn't these be the same?
Don't you just love it when a newbie asks all kinds of questions like this?
Thanks,
Parker
Shouldn't it be:
(joindate>=$datecut AND posts<=$joinpostsremove)
instead of:
(joindate<=$datecut AND posts<=$joinpostsremove)No, the newer the registration, the larger the number. (Which, I just realized makes some code invalid. I'll get to that later)
Also, the reason that I asked about the time stamp thing
is because my own joindate is listed as 867992400. I have been on our forum for 1122 days. If you multiply this by
the 86,400 you get 96940800. Shouldn't these be the same?That timestamp is seconds from Jan 1, 1970, not how long it's on the board.
I did the math, but now that I look at it, it didn't generate that number. I think my unix timestamp info may be wrong. I guess it's not 1970.
Just trust me with what I'm saying here :D
Now, next post will update the code a little...
Actually, I just made a mistake in my math, so now it works (forgot to subtract 1122)
(365 * 30) + 212 - 1122 = 10040 days since Jan 1, 1970
10,040 * 86,400 = 867456000 seconds since Jan 1, 1970
867456000
867992400
The small difference is because I didn't take into account for leap years.
Ok, did that - not NEXT post will update code.
Untested, and I only changed one line of code, but I think it should work now :)
Please note that if you type in "0" in days and like "1000000" in posts, it will probably delete ALL your users - admins included. There is no error checking or usergroup checking! (Although that's pretty simple) If this works, let me know and I'll add the checks!
if ($action=="joindates") {
echo "<p>Remove by length of membership</p>\n";
echo doformheader("thread","doremovejoindate");
echo "<table border=0>";
echo makeinputcode("Delete accounts older than x days:","joindateremove","");
echo makeinputcode("Number of Posts:","joinpostsremove","");
echo doformfooter("Submit");
exit;
} #end joindates
if ($action=="doremovejoindate") {
echo "<p>Deleting...</p>";
//Bah - screw the checking :)
$datecut=time()-($joindateremove*86400); //<-- the fix
// time() is NOW in unix timestamp, minus for older dates!
if($cuts=$DB_site->query("SELECT username,userid FROM user WHERE (joindate<=$datecut AND posts<=$joinpostsremove)")) {
while($user=$DB_site->fetch_array($cuts)) {
$DB_site->query("DELETE FROM user WHERE userid=$user[userid]");
echo "$user[username] deleted...<BR>";
}
echo "<p>Accounts removed successfully! It is recommend that you <a href=\"misc.php\">update counters</a> now.</p>";
} else {
echo "<p>No Members match this criteria. Click <a href=\"index.php\">here</a> to return to the admin index page.</p>";
}
} #end doremovejoindate
Ed:
I really appreciate all your hard work but it isn't working right.
I signed up today and it took me out because I had zero messages. And I set the number of days as 730 and the message count as zero.
Parker
Hmm... lemme go play around with this on my test board.
Ed:
Never mind. It worked. It took me out because I didn't have a sign up date.
Ok this working now how about those checks that you were talking about. Or is it a humbug? :)
Parker
Ok,
This is what I have so far.
In admin/index.php look for:
<p><b>Threads</b><br>
<a href="thread.php?action=prune">Prune</a><br>
<a href="thread.php?action=move">Move</a><br>
and below this add:
<a href="thread.php?action=remove">Remove</a><br>
<a href="thread.php?action=joindates">Join Date</a></p>
Then in thread.php
look for:
// ###################### Start move by user selected #######################
if ($action=="domoveuser") {
echo "<p>Deleting...</p>";
while (list($key,$val)=each($movethread)) {
if ($val==1) {
$DB_site->query("UPDATE thread SET forumid=$destforumid WHERE threadid=$key");
}
}
echo "<p>Posts moved successfully! It is recommend that you <a href=\"misc.php\">update counters</a> now.</p>";
}
and below this put.
// ###################### Start Remove by Account Date #######################
if ($action=="remove") {
echo "<p>Remove members by number of posts</p>\n";
echo doformheader("thread","doremoveposts");
echo "<table border=0>";
echo makeinputcode("Delete member by number of posts :","postsremove","");
echo doformfooter("Submit");
exit;
}
if ($action=="doremoveposts") {
echo "<p>Deleting...</p>";
if ($postsremove==0) {
$DB_site->query("DELETE FROM user WHERE posts=0");
}
elseif ($postsremove>=1) {
$DB_site->query("DELETE FROM user WHERE posts<=$postsremove");
}
echo "<p>Posts deleted successfully! It is recommend that you <a href=\"misc.php\">update counters</a> now.</p>";
}
// ###################### Start Remove by Join Date #######################
if ($action=="joindates") {
echo "<p>Remove by length of membership</p>\n";
echo doformheader("thread","doremovejoindate");
echo "<table border=0>";
echo makeinputcode("Delete accounts older than x days:","joindateremove","");
echo makeinputcode("Number of Posts:","joinpostsremove","");
echo doformfooter("Submit");
exit;
} #end joindates
if ($action=="doremovejoindate") {
echo "<p>Deleting...</p>";
$datecut=time()-($joindateremove*86400);
if($cuts=$DB_site->query("SELECT username,userid FROM user WHERE (joindate<=$datecut AND posts<=$joinpostsremove)")) {
while($user=$DB_site->fetch_array($cuts)) {
$DB_site->query("DELETE FROM user WHERE userid=$user[userid]");
echo "$user[username] deleted...<BR>";
}
echo "<p>Accounts removed successfully! It is recommend that you <a href=\"misc.php\">update counters</a> now.</p>";
} else {
echo "<p>No Members match this criteria. Click <a href=\"index.php\">here</a> to return to the admin index page.</p>";
}
} #end doremovejoindate
This will delete the member by the number of posts or by the time they have been a member and the number of posts they have.
Be sure to back up your original files before using this. I am really new at this stuff and I would use any of this with caution. It worked ok on my test board.
Ed:
If there is anything that you think should be added please feel free to add what you think is necessary.
Parker
[Edited by Parker Clack on 08-02-2000 at 02:02 AM]
Can you add a control panel options to delete all users that have not posted anything since X day (using the "last post" from their profile)
Thanks for this :-) it has saved me a lot of time
i'm really new at vbb and all....so can anyone tell me how to setup this hack?? (or maybe do a release with a readme :p)
i'd really love to have this hack as well, since i don't have my own domain, with only a few megs allowed in space....i need to make sure my resource don't run out :P hence, deleting the inactives....
any help would be appreciated :) thx in adv
This will delete the member by the number of posts or by the time they have been a member and the number of posts they have.
Parker, will it delete the member by the time they have been a member? or inactive member?
could you please post the total picture for installing the script
thanks
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.