Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-04-2005, 04:32 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default auto secondary usergroup

0k, i have codded this small plugin that is supposed to assign a secondary usergroup when the user reaches 50 posts, all based on a question asked on the register form, "Choose Letter A or B" so, this is supposed to work on that way, if a registered user have choosen A when they register, when they have reached 50 post, they should be able to be on the secondary usergroup "A" or of they have choosen B, the same effect has to occur when they reach 50 posts to be on the secondary usergroup B

Hook: newpost_process

PHP Code:
if($vbulletin->options['field5']=="A" AND $vbulletin->userinfo['posts']=="50")
{
$vbulletin->userinfo['membergroupsids'] = 9;
}

if(
$vbulletin->options['field5']=="B" AND $vbulletin->userinfo['posts']=="50")
{
$vbulletin->userinfo['membergroupsids'] = 10;

but that event isnt happening, so im not sure where is/are my error(s)

maybe the hook, maybe some wrong codding or maybe both things

thanks for your time
Reply With Quote
  #2  
Old 09-04-2005, 04:39 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't think this part is right:
Code:
$vbulletin->options['field5']
Try
Code:
$vbulletin->userinfo['field5']
Reply With Quote
  #3  
Old 09-04-2005, 04:48 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyhow they will only be in the group as long as they have exactly 50 posts, if they make 51, they will loose it again.
Reply With Quote
  #4  
Old 09-04-2005, 05:00 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also, you have to make sure that there are no other membergroupids.

What you should be doing, is adding them to the membergroup once they hit 50 and updating the group list in the database.

Swipe the code from my put user in secondary group at registration plugin and adapt that to suit your needs.

Amy
Reply With Quote
  #5  
Old 09-04-2005, 05:07 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks amykhar, im gonna try it and looks good

and Marco, so, i suppose i can use

PHP Code:
$vbulletin->userinfo['posts']>="50"
but that will make the script to update the usergroups each time someone makes a new post and is over 50 posts, making evrything for the cpu harder when i reach a big ammount of users, so, can you please give me any suggestions of what can i do this instead?
Reply With Quote
  #6  
Old 09-04-2005, 05:10 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this

userdata_presave
PHP Code:
if ($this->fetch_field('posts') >= 50)
{
    
$membergroupids $this->fetch_field('membergroupids');
    if (
$this->fetch_field('field5') == 'A' AND strpos(',9,'",$membergroupids,") === false)
    {
        
$this->set('membergroupids'"$membergroupids,9");
    } else if (
$this->fetch_field('field5') == 'B' AND strpos(',10,'",$membergroupids,") === false)
    {
        
$this->set('membergroupids'"$membergroupids,10");
    } 

Reply With Quote
  #7  
Old 09-04-2005, 05:14 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

0ka, gonna work with all this info thanks all
Reply With Quote
  #8  
Old 09-04-2005, 05:29 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didn't see any code in oyur example that is updating the database with the new usergroup, all i see from your example is only working in memory, that is why it would only work with exactly 50 posts.
Reply With Quote
  #9  
Old 09-04-2005, 05:31 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

... and only while making a new Post - doesn't make too much sense IMHO.
Reply With Quote
  #10  
Old 09-04-2005, 05:55 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

0k, frist sorry, im still learning to use vbulletin plugins and such, i dont have much experience with PHP neither, so this are my frist attemps to create something with vbulletin, so im doing a lot senseless things x_x

0k, now with amykhar mode i was looking what you said MarcoH, the need to save it on the db so it can be more handy and well, im not very sure of the customized mysql commands used on vb 3.5.0, i just can see what have amykhar on her mod.

in other hand im trying to run what you have posted KirbyDE and im having this message:

"Your Post is a duplicate of a post that you have posted in the last five minutes. You will be redirected to that Thread"
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 05:31 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.04081 seconds
  • Memory Usage 2,265KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)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
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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