vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   auto secondary usergroup (https://vborg.vbsupport.ru/showthread.php?t=95638)

White_Snake 09-04-2005 04:32 PM

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

amykhar 09-04-2005 04:39 PM

I don't think this part is right:
Code:

$vbulletin->options['field5']
Try
Code:

$vbulletin->userinfo['field5']

Marco van Herwaarden 09-04-2005 04:48 PM

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.

amykhar 09-04-2005 05:00 PM

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

White_Snake 09-04-2005 05:07 PM

thanks amykhar, im gonna try it and looks good :D

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?

Andreas 09-04-2005 05:10 PM

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");
    } 



White_Snake 09-04-2005 05:14 PM

0ka, gonna work with all this info :) thanks all

Marco van Herwaarden 09-04-2005 05:29 PM

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.

Andreas 09-04-2005 05:31 PM

... and only while making a new Post - doesn't make too much sense IMHO.

White_Snake 09-04-2005 05:55 PM

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"

Andreas 09-04-2005 06:11 PM

Erm - that can't be. The Code I posted doesn't touch Post/Thread Management at all.

White_Snake 09-04-2005 06:18 PM

hmmm gotta check then what is causing it

0k, i think i have cheched and everything was my error, now, another super newbie question

how does this works?
PHP Code:

$foo->fetch_field(bar

i can see this command also on Amykhar mod and well, im not very sure how this thing works, so any help is very apreciated :)


All times are GMT. The time now is 02:35 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.01304 seconds
  • Memory Usage 1,748KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (12)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