vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Auto-prune users once per month (https://vborg.vbsupport.ru/showthread.php?t=268010)

Alfa1 08-05-2011 12:30 PM

Auto-prune users once per month
 
I want to add a scheduled task that deletes all users that meet all of the following conditions:
- in the 'awaiting email confirmation' usergroup
- registered more than 60 days ago
- never posted.

I want to set the scheduled task to run once per month. I assume I would need to add a php file to the cron directory.

What should be in the php file?

kh99 08-05-2011 04:27 PM

I put together the attached file, you just need to put it in includes/cron and then do "Add New Scheduled Task" in the adminCP, and enter pruneusers.php as the Filename. Also, I used "Deleted {1} inactive users awaiting confirmation." as the log phrase ({1} is the count of users deleted).

I got the code from admincp/user.php so it should do the same thing as pruning users from the adminCP. It probably does more than necessary for "Users Awaiting Email Confirmation" (for instance it assigns any posts or threads to "guest"), but I thought it was better to just leave everything.

I have to admit, I only tested this with one user, so you may want to try it out on a test site first. I am pretty sure that the usergroup, join date, and post conditions work right, I just don't know what would happen if there were many users to delete. I didn't know how many could be done in a batch so I wrote it to do batches of 50, but I didn't test that feature.


[attachment removed - new version attached below].

Alfa1 08-05-2011 07:35 PM

Quote:

Originally Posted by kh99 (Post 2229780)
I put together the attached file

Thanks.

Quote:

Originally Posted by kh99 (Post 2229780)
I just don't know what would happen if there were many users to delete. I didn't know how many could be done in a batch so I wrote it to do batches of 50, but I didn't test that feature.

I mostly delete 250-500 users at a time / per month.

Konstantinos 08-06-2011 06:16 AM

<a href="https://vborg.vbsupport.ru/showthread.php?t=177403" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=177403</a>

kh99 08-06-2011 11:31 AM

Quote:

Originally Posted by Konstantinos (Post 2229992)

Ah...great. I searched before doing that but I somehow missed it. Thanks. :)

Alfa1 08-06-2011 03:29 PM

Quote:

Originally Posted by Konstantinos (Post 2229992)

That only moves to another usergroup, but doesnt delete.

Konstantinos 08-06-2011 04:19 PM

Quote:

Originally Posted by Alfa1 (Post 2230163)
That only moves to another usergroup, but doesnt delete.

it deletes them

Quote:

Has the ability to prune users that match ALL the following conditions:

1. Has not visited in the last x days (30 by default)
2. Has not posted in the last x days (30 by default)
3. Has x or fewer posts (0 by default)

kh99 08-06-2011 04:25 PM

1 Attachment(s)
Quote:

Originally Posted by Alfa1 (Post 2229840)
I mostly delete 250-500 users at a time / per month.

I'm not sure if you are planning to use this (after my warnings filled you with confidence :) ), but FWIW I tested it using 10 users and batches of 2, and I found that in fact there was a problem, so only half of the users were being deleted. I'm attaching a new version that fixes the problem.


All times are GMT. The time now is 04:31 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03700 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete