The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Add User to Secondary Usergroup Based on the Value of a Custom Profile Field at Reg. Details »» | |||||||||||||||||||||||||||
Add User to Secondary Usergroup Based on the Value of a Custom Profile Field at Reg.
Developer Last Online: Nov 2013
This version is for the SECONDARY group. The one for primary groups is here:
https://vborg.vbsupport.ru/showthread.php?t=82992 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 secondary user group based on that selection. 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 Secondary Group Based on Custom Profile 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') { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 10"; } else { $membergroupids = 10; } $userdata->set('membergroupids', $membergroupids); }]]></phpcode> </plugin> </plugins> Example: if you are checking your field to see if the value is male, you would change (change field number as needed): Code:
if ($user['field5'] == 'yes') Code:
if ($user['field5'] == 'male') Code:
$membergroupids = $membergroupids . ", 10"; And in this line as well, Code:
$membergroupids = 10; 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. ---------------- Example Gender Mod that separates users into secondary groups based on their gender. Don't forget, the values are case sensitive and the field numbers and usergroup numbers need to be changed to suit your site's setup. Code:
// Get the value for field 20 $gender = $vbulletin->db->query_first("SELECT * FROM userfield WHERE userid=".$vbulletin->userinfo['userid']); if ($gender['field20'] == 'male') { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 42"; } else { $membergroupids = 42; } $userdata->set('membergroupids', $membergroupids); } else { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 41"; } else { $membergroupids = 41; } $userdata->set('membergroupids',$membergroupids); } Show Your Support
|
Благодарность от: | ||
Insta-Gator |
Comments |
#112
|
|||
|
|||
mhh.. then must be an error in my syntax, i think. Maybe anyone has an idea what is wrong..
the main problem is that if i had to activate more than 1 user at the same time the users will be put in the same group, allthough they had different choices for the selected field. PHP Code:
groeken |
#113
|
|||
|
|||
Does this work for 3.7?
|
#114
|
||||
|
||||
|
#115
|
|||
|
|||
Doesn't work for me on 3.7 gold, database error apon sign up.
|
#116
|
|||
|
|||
So does it work on 3.7.1????
|
#117
|
|||
|
|||
Hey folks! I've read through this whole thread, and can't seem to find anyone with the same problem (except maybe Murty in post #63). It seems that the plugin works for most registrations, but a few users end up in the wrong category. To explain, I've got it set up so field5 is a single-selection menu where members/students pick their year of study. I have it set up so that if they pick "Year 1" from the pull-down (instead of the other options of "Year 2", "Year 3", "Year 4+", "Grad Student" or "Alumni/Other"), they're put in a special usergroup with different forum access (called "Year - 1"), while if they pick anything else, they're put in another usergroup (called "Year - Other").
Settings are like so: Set Default: Yes, Including a First Blank Field Required: Yes, at Registration and Profile Updating Field Editable by User: Only at Registration Private Field: No Field Searchable on Members List: Yes Show on Members List: Yes Every few days, I've been doing a search for students who have both "Year 1" chosen in the profile field, and are in "Year - Other" usergroup. If I'd set this up correctly, there shouldn't be any users found, but there are always a few. Any ideas? It might be important to mention that the board has a high registration volume at the beginning of the academic year, so we've had over 1000 new users in 48 days. PHP Code:
|
#118
|
|||
|
|||
Alright, so after doing 30 or so registrations is different browsers (and changing "Set Default" to "No", so that each registrant has so select the menu and choose an option (as opposed to first year's just seeing it already selected and leaving it), it seems it's an IE issues. After I changes the "Set Default" option, firefox never seems to have any problems (an it did once or twice before), but IE never puts them in the right category. They automatically end up in the usergroup indicated by the else statement (id:14 or "Year - Other"). Any ideas here folks? I'm baffled!
|
#119
|
|||
|
|||
sorry my english ist not the best
i have import the xml and befor i import this i have changed this like this: Code:
// Get the value for field 8 $user = $db->query_first(" SELECT field8 FROM " . TABLE_PREFIX . "userfield WHERE userid = " . $vbulletin->userinfo['userid'] . " "); if ($user['field8'] == 'weiblich') { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 10"; } else { $membergroupids = 10; } $userdata->set('membergroupids', $membergroupids); } I use VB 3.6.6 and on fild8 they have to select m?nnlich or weiblich (male or female), i want that all "weiblich" go to the secondary usergroup ladies which have the the ID:10. Can somebody help me??? |
#120
|
||||
|
||||
Dear amykhar & others,
I'd been looking for such mod for a long time. Will this one still work for 3.8? I'm affraid not.... Is there an updated version of some similar mod? Thanks a lot in advance! |
#121
|
|||
|
|||
Quote:
Same here.. I am in need of this hack. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|