PDA

View Full Version : Custom Scheduled Task - Looping through users in a usergroup


The)TideHunter(
04 Jun 2007, 20:51
Right, i've now made a subscription in accordance with the Coins i recently added thanks to some of the guys here.
But, there are quite a few subscriptions and i don't exactly want to manually add coins to each member in every subscription group.
So, im making some Sceduled Tasks, but i need to know a method that loops through every member in usergroup id x and does actions.

Thanks in advance.

Eikinskjaldi
05 Jun 2007, 03:59
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Alternatively, if it is exactly the same thing you want to do to every user...


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

saf-t scissors
05 Jun 2007, 04:01
I'm not familiar with the coin subscriptions, but finding members of a certain usergroup, modifying their accounts, and continuing to the next is fairly generic.

You'd need to create a query that accurately describes the users you want

$myusers = $vbulletin->db->query_read("
SELECT userid, (... etc)
FROM " . TABLE_PREFIX . "user
WHERE usergroupid=2 (or whichever group you want)
");

then just:

while ($myuser = $vbulletin->db->fetch_array($myusers))
{
do your thing
}


I'd recommend downloading a few different scheduled task add-ons and examining their code to get a better understanding of how to accomplish your goal. A bit of time with some example code and a test installation of your board, and you should have a working script in short order.

Hope that helps.

The)TideHunter(
06 Jun 2007, 16:59
Thanks alot guys, just what i needed.