Discuz Forum Management: Practical Tips for Deleting Users in Batch
When operating a Discuz forum, you will inevitably encounter situations where you need to delete users in batches, such as cleaning up junk users, Malicious users, etc. However, the backend of Discuz does not provide a direct function of deleting users in batches, so some skills and codes are needed to achieve the operation of deleting users in batches. This article will introduce some practical tips and specific code examples to help forum administrators manage and maintain the forum more efficiently.
You can delete users in batches by executing SQL statements. The following is a sample SQL statement for deleting all users whose registration time is before a certain date:
DELETE FROM pre_common_member WHERE regdate < UNIX_TIMESTAMP('2022-01-01');
Discuz provides some management interfaces that can Write a simple script to delete users in batches. The following is a sample PHP script to batch delete all users whose registration time is before a certain date through the Discuz interface:
<?php define('IN_DISCUZ', true); require './source/class/class_core.php'; $discuz = C::app(); $discuz->init(); $users = C::t('common_member')->fetch_all_by_regdate(0, UNIX_TIMESTAMP('2022-01-01')); foreach ($users as $user) { C::t('common_member')->delete($user['uid']); }
The above is a simple sample code, which needs to be customized and adjusted according to specific needs for actual use. .
Through the practical skills and specific code examples introduced in this article, I hope it can help forum administrators delete users in batches more conveniently and quickly, and improve the efficiency and quality of forum management. You must be careful when operating to ensure data security and user experience, so that the forum can always maintain good operating conditions.
The above is the detailed content of Discuz forum management: practical tips for batch deletion of users. For more information, please follow other related articles on the PHP Chinese website!