Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-05-2011, 01:30 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 08-05-2011, 05:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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].
Reply With Quote
  #3  
Old 08-05-2011, 08:35 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I put together the attached file
Thanks.

Quote:
Originally Posted by kh99 View Post
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.
Reply With Quote
  #4  
Old 08-06-2011, 07:16 AM
Konstantinos Konstantinos is offline
 
Join Date: Apr 2006
Posts: 443
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?t=177403" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=177403</a>
Reply With Quote
  #5  
Old 08-06-2011, 12:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Konstantinos View Post
Ah...great. I searched before doing that but I somehow missed it. Thanks.
Reply With Quote
  #6  
Old 08-06-2011, 04:29 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Konstantinos View Post
That only moves to another usergroup, but doesnt delete.
Reply With Quote
  #7  
Old 08-06-2011, 05:19 PM
Konstantinos Konstantinos is offline
 
Join Date: Apr 2006
Posts: 443
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Alfa1 View Post
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)
Reply With Quote
  #8  
Old 08-06-2011, 05:25 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Alfa1 View Post
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.
Attached Files
File Type: php pruneusers.php (4.8 KB, 16 views)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:05 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04076 seconds
  • Memory Usage 2,249KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (1)postbit_attachment
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete