Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2010, 02:35 AM
DaPro DaPro is offline
 
Join Date: Jan 2003
Location: CT, USA
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Usergroup Permissions based off Profile Options

Hi Guys,

Looking for a modification that would allow me to select a usergroup based off of a profile option.

For instance, if I had a question:

"Are you selling goods?"

And it is "Yes" or "No" values, I could specify:

If "Yes" change usergroup to X.

Would this be possible for vBulletin 4?
Reply With Quote
  #2  
Old 02-11-2010, 04:33 PM
DaPro DaPro is offline
 
Join Date: Jan 2003
Location: CT, USA
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry to do this, but is anyone willing to help with this?
Reply With Quote
  #3  
Old 02-12-2010, 04:57 PM
DaPro DaPro is offline
 
Join Date: Jan 2003
Location: CT, USA
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So I tried to do this myself and the code isn't working. Could someone look into this for me?

I made a plugin and it's hooklocation is profile_updateprofile

PHP Code:
$user $db->query_first("SELECT field6 FROM " TABLE_PREFIX .  "userfield WHERE userid = " $vbulletin->userinfo['userid'] . "");

if(
$user['field6'] == 'Yes' &&  $vbulletin->userinfo['usergroupid'] =='2') {
    
$userdata->set('usergroupid'10);
} elseif(
$user['field6'] == 'No' &&  $vbulletin->userinfo['usergroupid'] =='10') {
    
$userdata->set('usergroupid'2);

Could someone help me with this?

This is for vBulletin 4.0 by the way.
Reply With Quote
  #4  
Old 02-12-2010, 06:06 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

on which hook are you setting this? this code should run after the user has registered in the forum, therefore it should run depending if you are asking your users to validate their email or not and for the people who already are in there, you would need to run a script that will move them to the user group if your forum is too big, but if its small one, less than 50 users or so i suppose it can be done manually
Reply With Quote
  #5  
Old 02-12-2010, 06:13 PM
DaPro DaPro is offline
 
Join Date: Jan 2003
Location: CT, USA
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by White_Snake View Post
on which hook are you setting this? this code should run after the user has registered in the forum, therefore it should run depending if you are asking your users to validate their email or not and for the people who already are in there, you would need to run a script that will move them to the user group if your forum is too big, but if its small one, less than 50 users or so i suppose it can be done manually
Sorry, I guessed you missed it in my post:

"profile_updateprofile"

That's the hook I am using. I want users to be switched after they edit their profile not after they register. Since there is no promotion system that supports being based off profile fields, I need something like that.
Reply With Quote
  #6  
Old 02-12-2010, 06:17 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

okay, well, your code is requestin the db for data the vbulletin main array already contains, so, try this code and tell me if it works:

PHP Code:
if ($vbulletin->userinfo[field6] == 'Yes' AND $vbulletin->userinfo['usergroupid'] =='2')
{
    
$userdata->set('usergroupid'10);
}
elseif (
$vbulletin->userinfo[field6] == 'No' AND $vbulletin->userinfo['usergroupid'] =='10')
{
    
$userdata->set('usergroupid'2);

by the way, where did you found this $userdata->set() function? this seems to be a new trick for me
Reply With Quote
  #7  
Old 02-12-2010, 06:25 PM
DaPro DaPro is offline
 
Join Date: Jan 2003
Location: CT, USA
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by White_Snake View Post
okay, well, your code is requestin the db for data the vbulletin main array already contains, so, try this code and tell me if it works:

PHP Code:
if ($vbulletin->userinfo[field6] == 'Yes' AND $vbulletin->userinfo['usergroupid'] =='2')
{
    
$userdata->set('usergroupid'10);
}
elseif (
$vbulletin->userinfo[field6] == 'No' AND $vbulletin->userinfo['usergroupid'] =='10')
{
    
$userdata->set('usergroupid'2);

by the way, where did you found this $userdata->set() function? this seems to be a new trick for me
Unfortunately it isn't working. I guess it's just not going to work like I want. That's not my code, I just slightly (very slight) modified it to do what I need it to do for my purposes. Not sure where I originally found it.
Reply With Quote
  #8  
Old 02-12-2010, 06:29 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DaPro View Post
Unfortunately it isn't working. I guess it's just not going to work like I want. That's not my code, I just slightly (very slight) modified it to do what I need it to do for my purposes. Not sure where I originally found it.
the problem might be that userdata set, im not sure either exactly how it works, the if sections are fine, the problem is the userdata, ill check around to get the exact function but before it, i have a question:

why are you trying to edit the main group and not just add your members to a sub group? it would be much easier AND most of all, you wont overwrite a mod/admin permission if said person tweaks with that button
Reply With Quote
  #9  
Old 02-12-2010, 06:39 PM
DaPro DaPro is offline
 
Join Date: Jan 2003
Location: CT, USA
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by White_Snake View Post
the problem might be that userdata set, im not sure either exactly how it works, the if sections are fine, the problem is the userdata, ill check around to get the exact function but before it, i have a question:

why are you trying to edit the main group and not just add your members to a sub group? it would be much easier AND most of all, you wont overwrite a mod/admin permission if said person tweaks with that button
Will the Additional Usergroup overwrite anything in particular? Otherwise, I was just changing the usergroup because I figured that would be cleaner.
Reply With Quote
  #10  
Old 02-12-2010, 06:42 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if ($vbulletin->userinfo[field6] == 'Yes' AND $vbulletin->userinfo['usergroupid'] =='2')
{
$membergroupids $userdata->fetch_field('membergroupids');
        if (
$membergroupids)
        {
        
$membergroupids $membergroupids ", 10";
         }
        else
        {
       
$membergroupids 10;
        }
       
$userdata->set('membergroupids'$membergroupids);

}
elseif (
$vbulletin->userinfo[field6] == 'No' AND $vbulletin->userinfo['usergroupid'] =='10')
{
    
$userdata->set('usergroupid'2);

this code should add the user sucessfully, but im not sure how to remove a user from a usergroup, im not sure if there is such a thing as unset, that part is out of my rookie knwoledge, but, send me a PM and lets see what can i do for you

--------------- Added [DATE]1266007473[/DATE] at [TIME]1266007473[/TIME] ---------------

Quote:
Originally Posted by DaPro View Post
Will the Additional Usergroup overwrite anything in particular? Otherwise, I was just changing the usergroup because I figured that would be cleaner.
well, it might be cleaner but, if a co-admin / moderator clicks yes/no his main permission will be overwritten, even you run the risk to get your main permission overwritten, so, dont mess with main usergroups unless you *REALLY* know what you are doing, and as well i hope you are testing this in a password protected forum away from your live one
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:20 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.05191 seconds
  • Memory Usage 2,284KB
  • 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
  • (4)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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