View Full Version : auto update usergroup
Night Owl
11-17-2002, 01:13 PM
I have used c-pr0mpt's hack to create an extra page on my site.
What I am trying to do is create a php page where a user in usergroup Y can click the submit button and automatically be upgraded to usergroup X.
I already have the submit button, based on the one in the register template. I already have the php file created, just need to the query necessary to make the update automatically when the user clicks the submit button.
Also, how would I go about tracking the date a member makes this upgrade? I need some way to either automatically put the user back in usergroup Y after 30 days, or way for the admin to get a list of when people in usergroup X upgraded, so he can manually move the user back to group Y.
Thank you!
Xenon
11-17-2002, 02:48 PM
the query is just as easy:
UPDATE user SET usergroupid=X WHERE userid=yyy AND usergroupid=y
you just have to replce the variables..
the second paragraph: you need to add another field to the user-table via phpmyadmin
then when runing the query above, you should add a part: ,userupgradedate=".time()."
to automatically move him back to his old usergroup you can add this line at the end of your global.php:
if($bbuserinfo[usergroupid]==x and $bbuserinfo[userupgradedate]<time()-3600*24*30) {
$DB_site->query("UPDATE user SET usergroupid=y WHERE userid=$bbuserinfo[userid]");
}
Night Owl
11-17-2002, 02:54 PM
Originally posted by Xenon
the query is just as easy:
UPDATE user SET usergroupid=X WHERE userid=yyy AND usergroupid=y
you just have to replce the variables..
OK, I'm a little confused on this part. The actual php string will need to be something like this, right?
$DB_site->query("UPDATE user SET usergroupid=X WHERE userid=yyy AND usergroupid=y,userupgradedate=".time()."");
So, how will the script know what the userid is?
Xenon
11-17-2002, 03:17 PM
right, this would be the php-code.
you have to replace the yyy with $bbuserinfo[userid] so the script will know which the userid is ;)
Night Owl
11-17-2002, 03:28 PM
Aha! Thank you very much. :):):):):)
Night Owl
11-17-2002, 04:30 PM
I just tested this and when the user clicked the submit button I have on the page, she received a 404 error and the query didn't work. What have I done wrong? (Sorry so many questions -- this is my first "hack.")
Here is my php script:
<?php
error_reporting(7);
require('./global.php');
eval("dooutput(\"".gettemplate('forumtrial')."\");");
// ###################### Start Free Trial #######################
if ($HTTP_POST_VARS['action']=="addtrial") {
$DB_site->query("UPDATE user SET usergroupid=21 WHERE userid=$bbuserinfo[userid] AND usergroupid=2,userupgradedate=".time()."");
}
?>
Night Owl
11-17-2002, 05:42 PM
Oh, I also discovered that the code I added to globals.php had already started putting people in usergroup X back into usergroup Y. Argh!
Night Owl
11-17-2002, 06:22 PM
Wugh. One more thing occurred to me. How does one prevent someone who has already used the free trial, from trying it again after the first trial has expired...? Ack!
Xenon
11-18-2002, 04:09 PM
if they get a 404 error, you have made a wrong link....
the code cannot produce a 404, but if you have misspelled a link that could appear ;)
the last question: just add an ifclause: if($bbuserinfo[userupgradedate]>0) show_nopermission();
so as long as they have never been in group 21 the datevalue would be 0 so they can access the trial, but if they were in that group the datevalue is greater than 0 so they'll get a nopermission
Night Owl
11-19-2002, 12:55 AM
Thank you very much, Xenon. :)
Xenon
11-19-2002, 05:16 PM
You're welcome
midnightz
06-02-2003, 05:08 PM
Can you have a Default Auto PM or email sent when the user gets upgraded to the new usergroup?
Thanks
Xenon
06-02-2003, 06:22 PM
all you have to do, is to insert a new row into the privatemessage table :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.