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
  #12  
Old 07-16-2005, 04:52 PM
Christine's Avatar
Christine Christine is offline
 
Join Date: Oct 2001
Location: PA
Posts: 472
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Brinnie,

Unless you paid for copyright removal, at the least, the copyright needs to read:

vBulletin, Copyright ?2000 - 2005, Jelsoft Enterprises Ltd.

You don't have to keep version information, but the rest is required by Jelsoft.

Reply With Quote
  #13  
Old 07-17-2005, 06:57 AM
Brinnie's Avatar
Brinnie Brinnie is offline
 
Join Date: Jul 2005
Location: Louisiana
Posts: 360
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Christine
Brinnie,

Unless you paid for copyright removal, at the least, the copyright needs to read:

vBulletin, Copyright ?2000 - 2005, Jelsoft Enterprises Ltd.

You don't have to keep version information, but the rest is required by Jelsoft.

oh well, that's jelsofts problem.
I'm buying the full version next week, so...

anyone have sucess with this on Beta 4?
Reply With Quote
  #14  
Old 07-17-2005, 07:07 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brinnie
oh well, that's jelsofts problem.
I'm buying the full version next week, so...

anyone have sucess with this on Beta 4?
Wrong this is your problem. You must follow your license agreement.
Reply With Quote
  #15  
Old 07-17-2005, 07:09 AM
Brinnie's Avatar
Brinnie Brinnie is offline
 
Join Date: Jul 2005
Location: Louisiana
Posts: 360
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarcoH64
Wrong this is your problem. You must follow your license agreement.
of course...
Reply With Quote
  #16  
Old 07-17-2005, 03:07 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brinnie
oh well, that's jelsofts problem.
I'm buying the full version next week, so...

anyone have sucess with this on Beta 4?
It's running fine for me on Beta 4.
Reply With Quote
  #17  
Old 08-01-2005, 08:16 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't think you need the select query. I mean, the custom fields get passed on by the POST method. They should already be somewhere in the script. Get the values from there.
Reply With Quote
  #18  
Old 08-02-2005, 02:03 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You would think so, wouldn't you. But, if you look at the code, you'll see that what's passed in to the activation routine are two things: The username and the activation id.

Using the username, the code gets the userinfo BUT not all of it. It only gets what's in the user table. It doesn't get the profile fields. And, it never does a call to fetch_userinfo(). (Which would result in a query as well.)

If I weren't doing this as a plugin, I would have changed the query to do a left join and get the profile field stuff. But, I'm doing this as a plugin and can't change the query. Hence, the second query.

Amy
Reply With Quote
  #19  
Old 08-02-2005, 02:17 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah... Sorry, I did not notice that you were hooking it into the activation section. I thought you added the group right upon registration... :P
Reply With Quote
  #20  
Old 08-02-2005, 02:22 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope. I don't want unactivated users in secondary user groups.

I figured it was safer this way for all concerned because not everybody understands how secondary usergroup permissions work. They could end up with some nasty surprises by putting somebody in a secondary usergroup that has priv to post, view attachments, or whatever.

Yes, the answer is to severely limit secondary groups, but not everybody knows to do that.

Amy
Reply With Quote
  #21  
Old 10-07-2005, 12:02 AM
justindwhite justindwhite is offline
 
Join Date: Apr 2005
Location: Spartanburg, SC
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am getting a Parse error when the user tries to activate their account. Here is the plugin I used. Is everything OK? Anyone know the problem?

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

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


					if ($user['field9'] == 'OnLineRegulator')
		{
			$userdata->set('usergroupid', 11);
			
					if ($user['field9'] == 'OLR')
		{
			$userdata->set('usergroupid', 10);
			
					if ($user['field9'] == 'OLR ANZACs')
		{
			$userdata->set('usergroupid', 19);
			
					if ($user['field9'] == 'OLR Canada')
		{
			$userdata->set('usergroupid', 20);
			
					if ($user['field9'] == 'OLR Divas')
		{
			$userdata->set('usergroupid', 12);
			
					if ($user['field9'] == 'OLR Elite')
		{
			$userdata->set('usergroupid', 13);
			
					if ($user['field9'] == 'OLR GreatBritain')
		{
			$userdata->set('usergroupid', 25);
			
					if ($user['field9'] == 'OLR Holland')
		{
			$userdata->set('usergroupid', 22);
			
					if ($user['field9'] == 'OLR Spartan')
		{
			$userdata->set('usergroupid', 9);
						
					if ($user['field9'] == 'OLR United States')
		{
			$userdata->set('usergroupid', 24);
						
					if ($user['field9'] == 'OLR Coalition')
		{
			$userdata->set('usergroupid', 39);
						
					if ($user['field9'] == 'OLR Honorary Member')
		{
			$userdata->set('usergroupid', 38);
						
					if ($user['field9'] == 'Not A Member')
		{
			$userdata->set('usergroupid', 16);
			
		}]]></phpcode>
	</plugin>
</plugins>
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 10:27 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.04599 seconds
  • Memory Usage 2,318KB
  • 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
  • (4)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
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (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