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 |
#52
|
|||
|
|||
If I use moderated public groups, the user is active in this group without moderation. Is there a workaround?
|
#53
|
||||
|
||||
what do mean by moderated public group? A group where the leader must approve the members? This mod is not intended to work with such groups.
|
#54
|
|||
|
|||
Quote:
btw, I have checked all the userids and options of the custom field. I am using custom groups which are not public and emails must be verified by users. Here is the php code from the plugin... Code:
Plugin PHP Code // Get the value for field 5 $user = $db->query_first(" SELECT field5 FROM " . TABLE_PREFIX . "userfield WHERE userid = " . $vbulletin->userinfo['userid'] . " "); if ($user['field5'] == 'Year 9') { $userdata->set('usergroupid', 9); if ($user['field5'] == 'Year 10') { $userdata->set('usergroupid', 10); if ($user['field5'] == 'Year 11') { $userdata->set('usergroupid', 11); if ($user['field5'] == 'Year 12') { $userdata->set('usergroupid', 12); } |
#55
|
|||
|
|||
Hey. Well It was working for the secondary user-group. Although I found out that I needed one for the primary group. So Amykhar helped me out with this slight modification of the script... Works on my board (3.5.4).
PHP Code:
Paul F |
#56
|
||||
|
||||
Because this mod requires you to change the code for it to work, you really need to be careful when making the changes. You haven't closed the braces on your first three if clauses, which is what's giving you the parse errors. I'm sorry, but I can't keep fixing these problems on an individual basis here and am referring any further issues to my premium support forum.
|
#57
|
|||
|
|||
Hi Amy,
I need this mod to read a different field (referrer) rather than profile field. Basically the user is put into a usergroup based on what field is filled out as referrer (automatically passed from URL). Basically if they are my referral they are top dog permissions because they are somebody who I can trust, if a troll refers them then maybe they get put into a special group. Will this work do you think? Thx Matt |
#58
|
|||
|
|||
Quote:
I plan on having available more usergroups in the future, and would like to have the individual be able to type in the group they are entering (I'd have a link to the possibilities on the registration page). Also, has their been any changes so that this could work all the time (for example, they can change their usergroup as they like through edit profile)? Thanks. |
#59
|
|||
|
|||
can someone post some working, multi-item xml code? I got mine working for multiple raio buttons with the secondary code, but i switched all of those groups to 'non-joinable custom/primary' usergroups and now I get nothing showing up when Iclick the registration email link and I can't get it to work. I've trid every combination i can think of... Ive got the right field, correct spelling and syntax, groups... i think i need to see someone's successful code for a multi-item xml file to compare. tia
this is the code i have now that does not want to work: PHP Code:
|
#60
|
|||
|
|||
This installed beautifully, Amy! I'm all about automation and this cuts down on quite a bit of work for me. Thank you!
|
#61
|
||||
|
||||
happy to be of service
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|