PDA

View Full Version : If member of X, delete custom avatar


mixylplik3
09-14-2007, 06:16 PM
Members who pay for an upgraded account are allowed to have avatars. Those that do not pay do not get avatars. I originally set up the subscriptions to change the primary usergroup as opposed to adding them to a secondary group. This has broken the functionality that removes the custom avatar when their account expires.

There was a script for an older version of vB that would delete the custom avatar if the user was in the regular registered user group. It no longer works.

I'm looking for a script that will delete the custom avatar if the user is in a specific group.

Thanks.

WhaLberg
09-14-2007, 06:49 PM
Save it as a php file and upload to your forum home directory and run after uploading.


<?php
// we need global.php..
require_once('global.php');
// set the usergroupid for the users who are in..
$removeugid = 6;
// start..
$finduser = $db->query_read("SELECT userid FROM " . TABLE_PREFIX . "customavatar");
while ($print = $db->fetch_array($finduser))
{
$userid = $print['userid'];
$fugid = $db->query_read("SELECT username,usergroupid FROM " . TABLE_PREFIX . "user WHERE userid='$userid'");
while ($show = $db->fetch_array($fugid))
{
$user = $show['username'];
$usergroupid = $show['usergroupid'];
if ($usergroupid == $removeugid)
{
$removeavatar = $db->query_read("DELETE FROM " . TABLE_PREFIX . "customavatar WHERE userid='$userid'");
if ($removeavatar)
{
echo "Avatar of $user has been removed.<br />";
}
else
{
echo mysql_error();
}
}
}
}

?>


Do NOT forget to set the $removeugid..

mixylplik3
09-14-2007, 07:06 PM
Fantastic. Thank you!