Home > Article > Backend Development > Discuz forum maintenance: steps to delete users in batches with one click
In the process of Discuz forum management, we often encounter situations where we need to delete users in batches. In this case, we need to use the one-click batch deletion of users. This article will introduce specific operation steps, along with code examples, to help administrators complete user management work quickly and efficiently.
First, the administrator needs to log in to the Discuz backend management system. After successfully logging in, enter the user name and password, and click the "User" option in the left menu bar. Enter the user management page.
There will be a "Search User" box at the top of the user management page, and the administrator can filter out the users to be deleted as needed. Select the user you want to delete, then click the "Select User" operation button at the bottom of the page, select "Delete User" from the drop-down menu, and enter the user deletion operation page.
In the user deletion operation page, the administrator needs to select a reason for deleting the user. You can usually choose options such as "Clean up junk users" and "Illegal operations" to record the purpose of deleting users.
After confirming the reason for deletion, click the "Confirm deletion" button at the bottom of the page. The system will prompt you to confirm whether to delete the selected user. After confirmation, the system will delete the selected user accounts in batches.
The following is a simple PHP code example that implements Discuz's one-click batch deletion of users:
<?php define('IN_DISCUZ', true); require_once './source/class/class_core.php'; $discuz = C::app(); $discuz->init(); $uids = [1, 2, 3]; // 要删除的用户ID数组 foreach ($uids as $uid) { C::t('common_member')->delete_by_uid($uid); }
In the above code example, Discuz is first introduced The core class library then defines an array of user IDs to be deleted. By looping through the user ID array and calling the delete_by_uid
method to delete users, the function of batch deletion of users is realized.
Through the above steps and code examples, administrators can easily complete the user management of the Discuz forum and achieve batch deletion of users with one click. In the process of managing the forum, cleaning and maintaining user data in a timely manner will help maintain the good operating status of the forum and improve user experience and management efficiency. I hope this article is helpful to you, thank you for reading!
The above is the detailed content of Discuz forum maintenance: steps to delete users in batches with one click. For more information, please follow other related articles on the PHP Chinese website!