Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Add User to Primary Usergroup Based on Value of Custom Profile Field Details »»
Add User to Primary Usergroup Based on Value of Custom Profile Field
Version: 1.00, by amykhar amykhar is offline
Developer Last Online: Nov 2013 Show Printable Version Email this Page

Version: 3.5.0 Beta 1 Rating:
Released: 06-12-2005 Last Update: Never Installs: 59
Uses Plugins
 
No support by the author.

This version is for the PRIMARY group. Here is the one for secondary groups:

https://vborg.vbsupport.ru/showthread.php?t=82993

As far as plugins goes, this one is an advanced plugin because you WILL need to make some tweaks to suit your needs.

What this plugin does: If you have a custom profile field, for example one for gender, it checks to see if the user has selected a specific value and then assigns them to a primary user group based on that selection. This happens at the time the user activates their email account after registering.

Instructions for installation:
A. Create your custom profile field and make a note of the field number. (Or simply make a note of the field number of an existing field.)

B. Make a note of the value you are checking for. For example, you may be looking to see if your member selected "male" in your custom gender field.

C. Make a note of the usergroup number that you want to set the user to.

D. Here you have two options:
Option 1: Edit the attached XML file before you import it to change the field number, the value that you check for and the usergroupid. In my XML file, I am checking field5 to see if the value is yes and changing the usergroup to 10.

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
	<plugin active="1" product="vbulletin">
		<title>Put User In User Group Based on Field Value</title>
		<hookname>register_activate_process</hookname>
		<phpcode><![CDATA[// Get the value for field 5
        $user = $db->query_first("
			SELECT field5
			FROM " . TABLE_PREFIX . "userfield
			WHERE userid = " . $vbulletin->userinfo['userid'] . "
		");


		if ($user['field5'] == 'yes')
		{
			$userdata->set('usergroupid', 10);
		}]]></phpcode>
	</plugin>
</plugins>
If, for example, you want to check the value of field6, change field5 in the XML file to field6. If you are looking for "male" instead of "yes", change
Code:
if ($user['field5'] == 'yes')
to:

Code:
if ($user['field5'] == 'male')
And, finally, change the usergroup as appropriate. Instead of 10 in this line:
Code:
$userdata->set('usergroupid', 10);
substiture your usergroupid of choice.

Option 2: Import the XML file as is, open the plugin manager, and make your edits there.


NOTE: This mod works for forums that require users to verify their email address upon registration. If your forum does not require users to verify their email address, you will need to use a different hook. If I have time, I'll test that variation.

Amy

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #92  
Old 01-16-2007, 01:47 AM
DeMagH DeMagH is offline
 
Join Date: Oct 2006
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

after 2 months of using this with vbulletin v3.6.2 here is what is happening:
- most of the time it is working fine "80% of the time"
- sometimes instead of getting the user to the right group it gets him to REGISTERED "15%"
- sometimes the user fails to get the activation email "not sure if this is caused by this plug in or not, but this is the ONLY plug in hooked with user_activate_process" "5%"

This sample is taken from different 150 different registrations randomly from hotmail/gmail/yahoo/others users.

will disable it within 24 hours and wait for another month to see what will happen and if there will be any change in percentages given above.
Reply With Quote
  #93  
Old 02-02-2007, 02:38 AM
salata salata is offline
 
Join Date: Nov 2003
Posts: 252
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by salata View Post
i am having diffulculty getting this to work for me, i am using 3.5.4

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
	<plugin active="1" product="vbulletin">
		<title>Put User In User Group Based on Field Value</title>
		
<hookname>register_activate_process</hookname>
		<phpcode><![CDATA[// Get the value for field 25
        $user = $db->query_first("
			SELECT field25
			FROM " . TABLE_PREFIX . "userfield
			WHERE userid = " . $vbulletin->userinfo['userid'] . "
		");


		if ($user['field25'] == 'No')
		{
			$userdata->set('usergroupid', 36);
		}]]></phpcode>
	</plugin>
</plugins>


Bump!!
Reply With Quote
  #94  
Old 02-07-2007, 05:58 PM
wtrk wtrk is offline
 
Join Date: Jun 2005
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is there a way to do this to users after they have registered?

how can i force users who have already answered the question into the usergroup?
Reply With Quote
  #95  
Old 02-19-2007, 02:51 AM
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Location: New Zealand
Posts: 2,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey amy.. should this plugin work with NON custom profile fields? ie: default ones?

I have noticed a pattern with certain spambots, they always use 'Man' as field1.

Altering the plugin code to the following doesn't seem to work.

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


        if (
$user['field1'] == 'Man')
        {        
$userdata->set('usergroupid'8);
        } 
Any ideas?
Reply With Quote
  #96  
Old 03-30-2007, 06:25 PM
Benj's Avatar
Benj Benj is offline
 
Join Date: May 2006
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any ideas if this works with the latest version ?
Reply With Quote
  #97  
Old 03-30-2007, 06:32 PM
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Location: New Zealand
Posts: 2,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kinda.

Well, 90% of the time for me.
Reply With Quote
  #98  
Old 04-18-2007, 08:22 PM
vuiveclub vuiveclub is offline
 
Join Date: Dec 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does this mod work in <hookname>register_activate_process</hookname> only?
I don't wanna use email for registration.
Reply With Quote
  #99  
Old 05-20-2007, 05:49 PM
Medina Medina is offline
 
Join Date: Oct 2006
Location: the Netherlands
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*notification*
Reply With Quote
  #100  
Old 05-29-2007, 10:50 PM
Murty's Avatar
Murty Murty is offline
 
Join Date: Dec 2005
Location: South Australia
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey guys,

For those of you interested, a guy has created a modification that will move users to a specified usergroup depending on a profile field selection.
For me, when a user registers, they need to select whether they are male or female. Once they have registered, depending on whether they selected male or female, they get moved to the male or female user group i created.

You are able to get this mod by sending an email to: hugh@alaweb.com and requesting the 'user profile group modification'.
This mod was not made for free, so it will cost you $25.00 US.

I have tested it with vb 3.6.5 and it works great, highly recommend!

PM me if you want more info.
Reply With Quote
  #101  
Old 06-18-2007, 08:23 AM
Medina Medina is offline
 
Join Date: Oct 2006
Location: the Netherlands
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by paulfletcher View Post
Hey. Well It was working for the secondary user-group. Although I found out that I needed one for the primary group. So Amykhar helped me out with this slight modification of the script... Works on my board (3.5.4).

PHP Code:
switch($userinfo['field5'])
{
    case 
"A":    
        
$userdata->set('usergroupid'12);
    break;
    case 
"B":
        
$userdata->set('usergroupid'13);
    break;
    case 
"C":
        
$userdata->set('usergroupid'18);
    break;

Talk to you later,
Paul F

Hello,

I have made it like this;

switch($userinfo['field5'])
{
case "Male":
$userdata->set('usergroupid', 30);
break;
case "Female":
$userdata->set('usergroupid', 29);
break;
}

and added beneath the the plugin


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

if ($user['field5'] == 'Male')
{
$userdata->set('usergroupid', 30);
if ($user['field5'] == 'Female')
{
$userdata->set('usergroupid', 29);
}
switch($userinfo['field5'])
{
case "Male":
$userdata->set('usergroupid', 30);
break;
case "Female":
$userdata->set('usergroupid', 29);
break;
}
Am I doing this right?

Thanks for a reply, of any advanced person with this script
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 09:38 PM.


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.11697 seconds
  • Memory Usage 2,330KB
  • Queries Executed 25 (?)
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
  • (5)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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