vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Custom Scheduled Task - Looping through users in a usergroup (https://vborg.vbsupport.ru/showthread.php?t=148911)

The)TideHunter( 06-04-2007 05:51 PM

Custom Scheduled Task - Looping through users in a usergroup
 
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 06-05-2007 12:59 AM

[sql]
$uquery = $db->query_read("Select userid from user where usergroupid=something);
while ($users = $db->fetch_array($uquery)) {
do_somthing($users[userid]);
}
[/sql]

Alternatively, if it is exactly the same thing you want to do to every user...
[sql]
$db->query_write("Update user set coins=something where usergroupid=something")
[/sql]

saf-t scissors 06-05-2007 01:01 AM

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-06-2007 01:59 PM

Thanks alot guys, just what i needed.


All times are GMT. The time now is 05:43 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01769 seconds
  • Memory Usage 1,706KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete