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 |
#112
|
|||
|
|||
Someone needs to update this for 3.7 Gold. It's causing registration errors for my users.
|
#113
|
||||
|
||||
This is perfect for my forums but is this 3.7 Gold compatible?
|
#114
|
||||
|
||||
Anyone using this successfully on 3.7 gold or 3.7.1??
|
#115
|
|||
|
|||
I, too, really need this for 3.7.1!
|
#116
|
||||
|
||||
Just installed it on v3.7.3.
THANKS! This is the answer I've been looking for. It will automatically ban my spammers. Edit: Also works on 3.7.4 p1 |
#117
|
||||
|
||||
This is an old one but I love it.
Spammers usually enter the same number into my location profile field. Bam, automatic ban. Just banned two more. They have gotten past answering questions which I'm sure stops a few, and this mod is just another measure. |
#118
|
|||
|
|||
Thank you Amy this is exactly what my client needed to perfect their forums.
Now all I need to do is learn how to do something like this with a cron job so that users who are already registered can choose something in their profile to 'upgrade' their account and set their primary usergroup. |
#119
|
|||
|
|||
There we go, I went ahead and wrote a Scheduled Task that every 10 minutes would check for anybody in the primary group 'Registered users' with the custom profile field9 set to 'Yes' and move them to usergroup 9, and vice versa. Sorry in advance for unclean code and please don't hate.
Place the code in the box below in a .php script in your /includes/cron folder and create a new scheduled task pointing to that script. Replace 'field9' with the field you want to check. Replace 'Yes' and 'No' with the values of your field9 option. Replace 'New member' and 'Introductory grower/distributor' with your chosen user titles. Replace the usergroup numbers 2(Registered member) and 9(Custom usergroup) on the MySQL queries with the numbers of the usergroups you want to migrate to and from. Sorry I can't go into more detail, sort of in a hurry to get this job done for my client. I don't recommend attempting this if you are not comfortable editing SQL queries. Be sure to test this out on your forums using the 'Run now' option from the Scheduled Tasks section of the control panel, if you have messed up the syntax at all the control panel should return an error and send a copy of the error to the board owner via email. I recommend backing up your databases before trying this out just in case you do something wrong, I don't hold any responsibility for lost or corrupt data in your database. P.S. I recommend putting a notice in your custom usergroup description letting the user know that it can take up to 10 minutes for the changes to take effect to avoid confusion. (Or whatever interval you set your scheduled task job to.) PHP Code:
|
#120
|
|||
|
|||
Hi there,
Does it work on the latest vB 3.8? I need this. Thank you all. |
#121
|
||||
|
||||
i need this for the latest vb too!! can you please update it!!
thanks! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|