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 |
#72
|
|||
|
|||
is their any way to make this a hack with a user interface?
|
#73
|
||||
|
||||
It's not the kind of mod that's really conducive for a user interface. It's one of those set it once and never touch it again kinds of things.
|
#74
|
|||
|
|||
hmm.. i'd like to have it so that people can select from the list. the thing is, if i have a list of five options, say A B C D E, and then I end up adding a 6th option and still wanted to maintain the ABC order, I'd place it between the A and the B. the problem with that is, users who selected B are now changed because the list changed by one line. any ideas?
|
#75
|
|||
|
|||
ok this is what i did:
1. created new profile field: gender 2. value = 'M' or 'F' 3. created new usergroup: female usergroup id: 10 i have made the neccesary changes to the xml file and now the silly question. how do i upload it to my plug in manager. i just save text and upload? thanks and great hack. |
#76
|
|||
|
|||
AdminCP > Plugin System > Plugin Manager > Add New Plugin
I think this is what your looking for. Thanks, Paul |
#77
|
|||
|
|||
Oh, if you already have the plugin installed and you just want to make a code edit. Inside the Plugin Manager, click on the plugin you want to edit. Once the next page has loaded, located Plugin PHP Code... To the right of that is where you can edit your code.
Thanks, Paul |
#78
|
|||
|
|||
Quote:
|
#79
|
||||
|
||||
Right click - > 'Save As'
|
#80
|
|||
|
|||
lol. that easy uh?
well i just wanted to make sure, i havent uploaded a plug in yet. thanks again, this is a great hack, that i am going to use. |
#81
|
|||
|
|||
hello amy can you help me out. i thought i did everything right.
1. i added new usergroup = 10 2. i have gender field '7' 3. i have required email verification 4. i have gender required at time of registration 5. M or F this is what i have as php code: // Get the value for field 7 $user = $db->query_first(" SELECT field7 FROM " . TABLE_PREFIX . "userfield WHERE userid = " . $vbulletin->userinfo['userid'] . " "); if ($user['field7'] == 'F') { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 10"; } else { $membergroupids = 10; } $userdata->set('membergroupids', $membergroupids); } but when i enable the plug in, everything seems to go fine when registerring, but i get this message after following my registration link and logging in: Your account has already been activated so please try logging in. everytime i try to log in. can you please help with any suggestions. thanks. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|