hennanra
06-07-2009, 03:50 PM
I want to completely delete (not ban) an array of users (submitted by a checkboxs form) from the database, ie. deleting the users and automatically delete all their associated data eg. threads, posts ...
I've tried this code from 'user.php' but it only deletes users in the 'user' table not their associated data in other tables:
if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'doDelete')
{
$vbulletin->input->clean_array_gpc('p', array('userid' => TYPE_ARRAY));
$user_ids = $vbulletin->GPC['userid'];
// check user is not set in the $undeletable users string
$nodelete = explode(',', $vbulletin->config['SpecialUsers']['undeletableusers']);
foreach($user_ids as $user_id)
{
if (!in_array($user_id, $nodelete))
{
$info = fetch_userinfo($user_id);
if ($info['userid'] == $user_id)
{
//delete user
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_CP);
$userdm->set_existing($info);
$userdm->delete();
unset($userdm);
}
}
}
//
print_cp_message('<center>Successfully deleted selected user(s)!</center>', NULL, 0, NULL);
//
}
Any help would be appreciated.
Thank you.
I've tried this code from 'user.php' but it only deletes users in the 'user' table not their associated data in other tables:
if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'doDelete')
{
$vbulletin->input->clean_array_gpc('p', array('userid' => TYPE_ARRAY));
$user_ids = $vbulletin->GPC['userid'];
// check user is not set in the $undeletable users string
$nodelete = explode(',', $vbulletin->config['SpecialUsers']['undeletableusers']);
foreach($user_ids as $user_id)
{
if (!in_array($user_id, $nodelete))
{
$info = fetch_userinfo($user_id);
if ($info['userid'] == $user_id)
{
//delete user
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_CP);
$userdm->set_existing($info);
$userdm->delete();
unset($userdm);
}
}
}
//
print_cp_message('<center>Successfully deleted selected user(s)!</center>', NULL, 0, NULL);
//
}
Any help would be appreciated.
Thank you.