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
  #32  
Old 11-08-2005, 07:05 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nobody has seniority at registration time, so no. This mod can't help you. You can use the built in promotion system, I believe.

Amy
Reply With Quote
  #33  
Old 11-08-2005, 07:23 PM
silly rabbit silly rabbit is offline
 
Join Date: Oct 2005
Location: Atlanta/NYC
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by amykhar
Nobody has seniority at registration time . . .
Amykhar, already have 'senority' as a required 'custom' field upon registration?? Granted don't have 'input verification' yet . . .

Marry Me? Rabbit (with respect)
Reply With Quote
  #34  
Old 11-08-2005, 07:25 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Doh. Sorry for my stupid initial response. Let me look at it a bit and get back to you. I'm multitasking right now.
Reply With Quote
  #35  
Old 11-08-2005, 07:28 PM
silly rabbit silly rabbit is offline
 
Join Date: Oct 2005
Location: Atlanta/NYC
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by amykhar
Let me look at it a bit and get back to you. I'm multitasking right now. . . .
No Problem!!!

Quote:
Originally Posted by amykhar
You can use the built in promotion system
I'm Not READING either - need to check out as well(if referring to 'posts' have already)

Thx Will Check Back LATER!!

Rabbit
Reply With Quote
  #36  
Old 11-08-2005, 07:36 PM
lazyseller lazyseller is offline
 
Join Date: Oct 2003
Posts: 178
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by amykhar
It sounds like if a user registers from one domain, you want them to see one style and one set of forums and if they register from another domain, you want them to see a different style and set of forums. Is that what you are going for?

Amy
Thanks... for responding i have found a solution for this ..
Reply With Quote
  #37  
Old 11-10-2005, 11:47 AM
webspider webspider is offline
 
Join Date: Jun 2003
Location: Canada
Posts: 175
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice mod I wondered how to do this.

I'm using this mod to ask the user if they wish to receive the site newsletter or not. This works fine on registration but they can't change their minds. So I added the option and two plugin's for the user to select yes or no on update profile. The problem I'm having is it does not always work I have to select Yes or No and save twice for the plugin to actually do the job of moving the user from one group to the other.

Is there anyway to combine these two options into one and is there a more sure way to ensure that the update actually occurs?

Hook Location profile_updateprofile

// 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', 2);
}

AND

// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");
if ($user['field5'] == 'No')
{
$userdata->set('usergroupid', 44);
}
Reply With Quote
  #38  
Old 12-30-2005, 05:24 AM
Token55 Token55 is offline
 
Join Date: Dec 2005
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey there,

This is exactly what I want to do, but I'm having a little trouble with it. I'm checking the correct field for the correct value (field6 is populating properly & I'm checking for the right values). It's hooked at the right place, register_activate_process.

I am using vB 3.5.2 - is that the problem? If so, any thoughts on how to get this to work?

Here's the code I'm using:

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 6
        $user = $db->query_first("
			SELECT field6
			FROM " . TABLE_PREFIX . "userfield
			WHERE userid = " . $vbulletin->userinfo['userid'] . "
		");


		if ($user['field6'] == 'chicago')
		{
			$userdata->set('usergroupid', 11);
		}
		if ($user['field6'] == 'cincinnati')
		{
			$userdata->set('usergroupid', 10);
		}
		if ($user['field6'] == 'indianapolis')
		{
			$userdata->set('usergroupid', 9);
		}

  ]]> 
  </phpcode>
  </plugin>
  </plugins>
The values for field6 are set up to be all lowercase.

When I click the activation link in the email, a blank window pops up with this address...
http://www.mydomain.com/forums/regis...=15&i=80639843
...but it freezes there. The user gets activated, but is not assigned to the desired usergroup.

Thanks a bunch for any help.
Reply With Quote
  #39  
Old 01-24-2006, 11:17 PM
Crrrazzzy Crrrazzzy is offline
 
Join Date: Sep 2005
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

fixed
Reply With Quote
  #40  
Old 01-29-2006, 05:20 PM
Valentino Valentino is offline
 
Join Date: Jan 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great plugin Amy!

I'm wondering if you (or any other able person) would help me? I want to use the plugin, but I don't have email verification turned on. What do I need to change to make this work without email verification?

Val
Reply With Quote
  #41  
Old 02-11-2006, 02:51 PM
Valentino Valentino is offline
 
Join Date: Jan 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can anyone help me?
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 03:03 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.05050 seconds
  • Memory Usage 2,315KB
  • 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
  • (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