PDA

View Full Version : Add custom MySQL query in Admin CP drop-down


djbaxter
09-07-2006, 10:00 PM
I wanted a fast way to access the subscribed list for my forum newsletter, for which I had added a custom variable. The technique below could be used for any MySQL query that you may want to add to the predefined "Automatic Query" drop down list in the Admin CP.

Open /admincp/queries.php

Find

'210' => $vbphrase['subscribe_choice_none'],
'220' => $vbphrase['subscribe_choice_0'],
'230' => $vbphrase['subscribe_choice_1'],
'240' => $vbphrase['subscribe_choice_2'],
'250' => $vbphrase['subscribe_choice_3'],


Add before

'209' => 'List users subscribed to newsletter',

Find

case 210:
$query = "UPDATE " . TABLE_PREFIX . "user SET autosubscribe = -1";
break;


Add before

case 209:
$query = "SELECT username from " . TABLE_PREFIX . "user WHERE subscribenews=1";
break;


SAVE and UPLOAD.

You will need to edit the above for your own variable and table names, of course. Also do a FIND to ensure that the CASE is not already in use.

Been Told
11-24-2006, 07:50 PM
Nice! :)
I use that to insert a query to empty the chatbox. Thanks :)

msibm
02-21-2007, 03:18 PM
Nice!
Thanks!

ZomgStuff
02-21-2007, 10:11 PM
Reserved! Thanks!

gator777
03-23-2007, 07:17 PM
Installed! I wish the VB guys would make this a feature. Thanks for the info. :D

TMSBrad
07-28-2008, 02:09 PM
Very nice. Used it for my Master Member List which includes custom profile fields. Thanks.