The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
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
Developer Last Online: Nov 2013
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> Code:
if ($user['field5'] == 'yes') Code:
if ($user['field5'] == 'male') Code:
$userdata->set('usergroupid', 10); 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
|
Comments |
#72
|
||||
|
||||
Working fine for me on 3.6.0 and 3.6.1
|
#73
|
|||
|
|||
I thought it wasn't working, but then through troubleshooting I realized that the value of my field couldn't have both numbers and letters. I switched it to just letters and my test account was properly switched into the new usergroup.
If I want to set up multiple "custom registration codes," can I duplicate this script and rename it, changing the values? |
#74
|
|||
|
|||
Quote:
Amy this hack is exactly what I have been looking for except I have a couple of questions. I've set up a custom user profile field that asks the user upon registration if they are a reatil buyer or wholesaler and I'm using a radio button to ask them. Now with your code if they select on item it puts them in a certain user group, but what if they pic the other? do they just go in the default user group? I want it to place them in eaither group depending on what they pic. I hope this makes sense. |
#75
|
||||
|
||||
This mod is more of a template for you to decide what you want to do with users based on that profle field. You code the logic of where they are sorted. The mod itself hooks to the right place and gets you started so you can see how to inspect the value of the field and how to put the user in a group.
|
#76
|
|||
|
|||
Quote:
Could you help me out with this ... say my user field is 5 and my options are Dealer or End User my user group for Dealers is 10 and my user group for End Users is 11 would my code look something like this???: Code:
if ($user['field5'] == 'Dealer') { $userdata->set('usergroupid', 10); if ($user['field5'] == 'End User') { $userdata->set('usergroupid', 11); |
#77
|
|||
|
|||
Installed, it would be helpful to my forum
|
#78
|
|||
|
|||
I need this plugin for my forum.
|
#79
|
||||
|
||||
Quote:
(It works on 3.5.x and 3.6.x). |
#80
|
|||
|
|||
Quote:
I think that all vBb customers use the newest vBb version. |
#81
|
||||
|
||||
Quote:
Quote:
|
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|