Log in

View Full Version : Mass Delete User Albums


Chadi
03-28-2011, 11:07 AM
<blockquote> How do I mass delete all user albums in 3.8? </blockquote>

Chadi
04-09-2011, 11:00 AM
Can someone please help?

CRDeveloper
04-10-2011, 09:19 PM
I need to do it on vb 4 too!

Chadi
04-18-2011, 05:37 PM
Anyone? Thanks

kh99
04-18-2011, 08:01 PM
Warning: try this at your own risk - back up your database first. There is no "are you sure you want to do this message". You have been warned.

I only did one test to see if this worked at all (on vb 3.8.3 - I have no idea if this will work for vb4), but here it is: make a plugin using hook location admin_maintenance and this code:

if ($_REQUEST['do'] == 'deleteallalbums')
{
require_once(DIR . '/includes/functions_album.php');
print_dots_start("Deleting all albums ");
do
{
$albuminfo = $vbulletin->db->query_first("
SELECT album.*, user.username
FROM " . TABLE_PREFIX . "album AS album
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (album.userid = user.userid)"
);
if (!$albuminfo)
{
break;
}
$albumdata =& datamanager_init('Album', $vbulletin, ERRTYPE_STANDARD);
$albumdata->set_existing($albuminfo);
$albumdata->delete();
} while (1);
print_dots_stop();
print_cp_message("Done.",
defined('CP_REDIRECT') ? CP_REDIRECT : NULL,
1,
defined('CP_BACKURL') ? CP_BACKURL : NULL,
defined('CP_CONTINUE') ? true : false
);
}


Then when you're sure you're ready to try it, type in the url [your forum]/admincp/misc.php?do=deleteallalbums .

You probably now want to delete or at least disable that plugin.

ETA: for anyone who feels like confirming it's legit - I used the code from the file album.php, the "do == killalbum" section that gets called when a user deletes an album. The first query I got from fetch_albuminfo() in includes/functions_album.php (but I removed the WHERE for the userid).

Chadi
04-18-2011, 08:59 PM
Thanks for your help. Can any coder here confirm this plugin looks legit?

paulgee
10-12-2013, 01:51 PM
there is an easier way?

if you don't want albums at all just switch them off i.e.
in vboptions > user profile options > enabled profile features

then back up your database............

to remove all existing albums use phpmyadmin, locate usually VB# albums and select it then click empty on you phpadmin panel.

you can do this with album images as well. :D

doing this saved me tons of space in my database and stopped spammers using the albums area as a spamming tool.

Regards
Paul

yotsume
08-29-2015, 03:45 PM
In VB 37x I need a way to delete orphaned albums of users that were deleted who had created albums. When these users were deleted their albums remain and can NOT be accessed but their thumbnails show up.

I would rather keep albums of current members...

UPDATE: Silly me! The solution is way too simple. Just use phpmyadmin and delete the tables in vb_album related to the orphaned User IDs. PROBLEM SOLVED!