vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Usergroup Permissions based off Profile Options (https://vborg.vbsupport.ru/showthread.php?t=235372)

DaPro 02-09-2010 02:35 AM

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?

DaPro 02-11-2010 04:33 PM

Sorry to do this, but is anyone willing to help with this?

DaPro 02-12-2010 04:57 PM

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.

White_Snake 02-12-2010 06:06 PM

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

DaPro 02-12-2010 06:13 PM

Quote:

Originally Posted by White_Snake (Post 1980943)
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.

White_Snake 02-12-2010 06:17 PM

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

DaPro 02-12-2010 06:25 PM

Quote:

Originally Posted by White_Snake (Post 1980952)
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.

White_Snake 02-12-2010 06:29 PM

Quote:

Originally Posted by DaPro (Post 1980958)
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

DaPro 02-12-2010 06:39 PM

Quote:

Originally Posted by White_Snake (Post 1980960)
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.

White_Snake 02-12-2010 06:42 PM

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 :p

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

Quote:

Originally Posted by DaPro (Post 1980962)
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


All times are GMT. The time now is 04:07 AM.

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.01488 seconds
  • Memory Usage 1,765KB
  • 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
  • (4)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete