Skip to content

Instantly share code, notes, and snippets.

@GerB
Created October 11, 2018 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GerB/6250b109c37cbccc921f9c703eadf5f2 to your computer and use it in GitHub Desktop.
Save GerB/6250b109c37cbccc921f9c703eadf5f2 to your computer and use it in GitHub Desktop.
Script for phpBB 3.2 to delete all users in Newly registers users group
<?php
/**
*
* @package phpBB3
* @author GerB https://github.com/GerB
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
// Connect to phpBB
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Sanity check
if ($user->data['user_type'] != USER_FOUNDER)
{
trigger_error('This script is only available for founders');
}
// Get correct group id
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name = 'NEWLY_REGISTERED'
AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql);
$group = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// Get users from this group and add to list
$sql2 = 'SELECT user_id
FROM ' . USER_GROUP_TABLE . '
WHERE group_id = ' . $group['group_id'];
$result2 = $db->sql_query($sql2);
while ($user = $db->sql_fetchrow($result2))
{
$deleteArray[] = $user['user_id'];
}
$db->sql_freeresult($result2);
// Now go and report
user_delete('remove', $deleteArray);
$count = (int) count($deleteArray);
echo '<pre>' . $count . ' users removed. Now please remove this script from your public HTML.</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment