vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Automatically change usergroup after certain amount of time (https://vborg.vbsupport.ru/showthread.php?t=59248)

zsmom 12-18-2003 01:08 AM

Automatically change usergroup after certain amount of time
 
I would like there to be a way for members' usergroups to automatically change to a different one after a certain amount of time since their last post.

This seems like it would be fairly simple to do, but I have no idea.
Or is there a way to do this already?

Logician 12-18-2003 09:14 AM

do you want to change at the moment they revisited the board or even if they dont revisit? If latter, it will require a cron script.

Zachery 12-18-2003 10:55 AM

could be done with vb3 very simply as its a built in feature

zsmom 12-18-2003 11:26 AM

I'd prefer it to change even if they don't revisit. But either way would be fine with me. It beats having to do it manually, that's for sure.

Logician 12-18-2003 05:56 PM

let us know:
a) Usergroups the hack will apply
b) New Usergroup hack will put users in
c) Time hack will check

zsmom 12-18-2003 08:05 PM

Ok...usergroups 9 and 11 would change to usergroup 2 at 30 days since last post. And I guess it would check this once per day, midnight I guess, though that part doesn't matter much.

Thanks!!!

Logician 12-18-2003 09:03 PM

Create a "anynameyouwant.php" file in your forum directory and put this code inside that file:
PHP Code:

<?php
   set_time_limit
(900); 
   require(
'./global.php');

   
$userArray=$DB_site->query("SELECT * FROM user WHERE (usergroupid=9 OR usergroupid=11) AND posts>0");

   while (
$user=$DB_site->fetch_array($userArray)) 
       {
       
$days mktime (date("H"), date("i"), date("s"), date("m"), date("d")-30date("Y"));
    
       
$lastpost=$DB_site->query_first("SELECT dateline FROM post WHERE visible=1 AND userid='$user[userid]' ORDER BY dateline DESC LIMIT 1");
         if (
$lastpost[dateline]>AND $lastpost[dateline]>$days)
           {
           
$DB_site->query("UPDATE user SET usergroupid=2 WHERE userid='$user[userid]'");
           }

       }
?>

Now configure your CRON job to run this file once everyday at any time you like.

Please test this script in a test board first! I dont expect a problem but I don't like giving away scripts like this as they make changes in DB so a bug can create serious problems. I didnt test the script myself.

zsmom 12-20-2003 01:20 AM

Thank you so much! I'll give it a whirl...

g-force2k2 12-20-2003 05:03 AM

Question Logician, what exactly does set_time_limit( ) function do? I appreciate any assistance.

Regards,
g-force2k2

zsmom 12-20-2003 07:11 AM

Ok, I tried it and it changes everyone in usergroups 9 & 11, regardless of the time since their last post, to usergroup 2. Any ideas?

Logician 12-20-2003 07:20 AM

Quote:

Originally Posted by zsmom
Ok, I tried it and it changes everyone in usergroups 9 & 11, regardless of the time since their last post, to usergroup 2. Any ideas?

himm the line:
PHP Code:

if ($lastpost[dateline]>AND $lastpost[dateline]>$days

should be

Quote:

if ($lastpost[dateline]>0 AND $lastpost[dateline]<$days)
It was not changing everyone but it was changing who posted in the last 30 days. Since you asked for the opposite, new line should do the trick ;)

PHP Code:

what exactly does set_time_limit( ) function do? I appreciate any assistance

buddy, by default PHP scripts are granted 30 seconds running time. (unless it is set otherwise in php configuration). If they exceed 30 seconds, they time out. However some scripts may need more running time so you can set how many seconds a script can run before it times out with set_time_limit() command.

I thought this script might take some time if user database is large so I put this command in the begining just in case to prevent time out error. :)


All times are GMT. The time now is 03:32 PM.

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.01027 seconds
  • Memory Usage 1,746KB
  • 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
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)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