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

Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2010, 05:40 PM
wtrk wtrk is offline
 
Join Date: Jun 2005
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default moving people to usergroups automatically

im using vb 3.-latest and i have a question about moving users to a usergroup based on profile filed answers. in previous version of vbulletin i swear this worked as a plugin with a hook of register_activate_process:

Code:
// Get the value for field 
        $user = $db->query_first(" 
            SELECT field7 
            FROM " . TABLE_PREFIX . "userfield 
            WHERE userid = " . $vbulletin->userinfo['userid'] . " 
        "); 

// change user groups

        if ($user['field7'] == 'yes') 
        { 
            $userdata->set('usergroupid', 23); 
        } 
if ($user['field7'] == 'no') 
        { 
            $userdata->set('usergroupid', 24); 

        }
can somebody help me get this to work?
Reply With Quote
  #2  
Old 11-07-2010, 05:49 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you moderating users? If so, that isn't going to work.
Reply With Quote
  #3  
Old 11-07-2010, 06:31 PM
wtrk wtrk is offline
 
Join Date: Jun 2005
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no not moderating users.
Reply With Quote
  #4  
Old 11-07-2010, 08:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't understand all the details of the registration process, but looking at register.php where that hook is called it looks like there's code above that that uses the group id, so I think your code might need to repeat some of that.
Reply With Quote
  #5  
Old 11-07-2010, 08:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So they sign up and immediately become a registered user (except you want them to go to another usergroup)? (Isn't there a mod that does this?)
Reply With Quote
  #6  
Old 11-07-2010, 08:20 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I haven't tried this at all, but if I had to guess I'd say your code should be something like:

PHP Code:
// Get the value for field 
$user $db->query_first(
SELECT field7 
FROM " 
TABLE_PREFIX "userfield 
WHERE userid = " 
$vbulletin->userinfo['userid'] . 
"
); 

// change user groups

if ($user['field7'] == 'yes'
    
$newgroup 23
else 
    
$newgroup 24;

$getusergroupid iif($userinfo['displaygroupid'] != $userinfo['usergroupid'], $userinfo['displaygroupid'], $newgroup);

$user_usergroup =& $vbulletin->usergroupcache["$newgroup"];
$display_usergroup =& $vbulletin->usergroupcache["$getusergroupid"];
$userdata->set('usergroupid'$newgroup);
$userdata->set_usertitle(
    
$user['customtitle'] ? $user['usertitle'] : '',
    
false,
    
$display_usergroup,
    (
$user_usergroup['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canusecustomtitle']) ? true false,
    (
$user_usergroup['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cancontrolpanel']) ? true false
);

if (
$user['userid'] == $vbulletin->userinfo['userid'])
{
    
$vbulletin->userinfo['usergroupid'] = $newgroup;
    
$vbulletin->userinfo['displaygroupid'] = $newgroup;

ETA: (oops - posted this before I read Lynne's. Maybe there is an existing mod).
Reply With Quote
  #7  
Old 11-09-2010, 03:37 PM
FreshFroot's Avatar
FreshFroot FreshFroot is offline
 
Join Date: Jul 2005
Posts: 770
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wait..? can't you use the promotion method. Where you can set X posts, date...etc..etc.. to push a user into a certain usergroup?
Reply With Quote
  #8  
Old 11-09-2010, 04:51 PM
wtrk wtrk is offline
 
Join Date: Jun 2005
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by FreshFroot View Post
wait..? can't you use the promotion method. Where you can set X posts, date...etc..etc.. to push a user into a certain usergroup?
Quote:
Originally Posted by Lynne View Post
So they sign up and immediately become a registered user (except you want them to go to another usergroup)? (Isn't there a mod that does this?)
I looked high and low for a mod that does this. I originally think I got that code or the idea for that from a post somewhere here on vborg (but I cant find it, the search sucks here).

I dont want to promote the user based on post, date, etc. but by profile field.
Reply With Quote
  #9  
Old 11-09-2010, 09:21 PM
FreshFroot's Avatar
FreshFroot FreshFroot is offline
 
Join Date: Jul 2005
Posts: 770
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by wtrk View Post
I looked high and low for a mod that does this. I originally think I got that code or the idea for that from a post somewhere here on vborg (but I cant find it, the search sucks here).

I dont want to promote the user based on post, date, etc. but by profile field.
hmm the easy way would be to use the promotion system, but modify it to work for profile fields. The problem would be if the fields are editable or not? If they are say a selection of options, then it's easy to do.

If they can type anything in then it's going to be a tough one.
Reply With Quote
  #10  
Old 11-10-2010, 03:03 PM
wtrk wtrk is offline
 
Join Date: Jun 2005
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Im trying to make it as simple as possible by just using single-selection radio buttons and only giving a 'yes' or 'no' option. im not a programmer, ive got pretty basic php/mysql skills.

update: there is a plugin to move users on registration, but none to move users on profile update.
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 02:26 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04699 seconds
  • Memory Usage 2,273KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_php
  • (3)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
  • (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