Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
auto update usergroup Details »»
auto update usergroup
Version: , by Night Owl Night Owl is offline
Developer Last Online: Feb 2010 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 11-17-2002 Last Update: Never Installs: 0
 
No support by the author.

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!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 11-17-2002, 02:48 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the query is just as easy:

[sql]UPDATE user SET usergroupid=X WHERE userid=yyy AND usergroupid=y[/sql]
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:
PHP Code:
if($bbuserinfo[usergroupid]==and $bbuserinfo[userupgradedate]<time()-3600*24*30) {
$DB_site->query("UPDATE user SET usergroupid=y WHERE userid=$bbuserinfo[userid]");

Reply With Quote
  #3  
Old 11-17-2002, 02:54 PM
Night Owl Night Owl is offline
 
Join Date: May 2002
Location: Oklahoma
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Xenon
the query is just as easy:

[sql]UPDATE user SET usergroupid=X WHERE userid=yyy AND usergroupid=y[/sql]
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?

PHP Code:
$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?
Reply With Quote
  #4  
Old 11-17-2002, 03:17 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 11-17-2002, 03:28 PM
Night Owl Night Owl is offline
 
Join Date: May 2002
Location: Oklahoma
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Aha! Thank you very much.
Reply With Quote
  #6  
Old 11-17-2002, 04:30 PM
Night Owl Night Owl is offline
 
Join Date: May 2002
Location: Oklahoma
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 Code:
<?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()."");

}

?>
Reply With Quote
  #7  
Old 11-17-2002, 05:42 PM
Night Owl Night Owl is offline
 
Join Date: May 2002
Location: Oklahoma
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #8  
Old 11-17-2002, 06:22 PM
Night Owl Night Owl is offline
 
Join Date: May 2002
Location: Oklahoma
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #9  
Old 11-18-2002, 04:09 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #10  
Old 11-19-2002, 12:55 AM
Night Owl Night Owl is offline
 
Join Date: May 2002
Location: Oklahoma
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much, Xenon.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:54 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.04335 seconds
  • Memory Usage 2,297KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete