vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   moving people to usergroups automatically (https://vborg.vbsupport.ru/showthread.php?t=253314)

wtrk 11-07-2010 05:40 PM

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?

Lynne 11-07-2010 05:49 PM

Are you moderating users? If so, that isn't going to work.

wtrk 11-07-2010 06:31 PM

no not moderating users.

kh99 11-07-2010 08:13 PM

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.

Lynne 11-07-2010 08:14 PM

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?)

kh99 11-07-2010 08:20 PM

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).

FreshFroot 11-09-2010 03:37 PM

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?

wtrk 11-09-2010 04:51 PM

Quote:

Originally Posted by FreshFroot (Post 2119922)
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 (Post 2119204)
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.

FreshFroot 11-09-2010 09:21 PM

Quote:

Originally Posted by wtrk (Post 2119956)
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.

wtrk 11-10-2010 03:03 PM

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.


All times are GMT. The time now is 02: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.02276 seconds
  • Memory Usage 1,753KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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